473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Dynamically generate text in a form text box

Hi,

I'm somewhat familiar with access and vb programming (I can read someone else's code, for the most part), but I'm still very green when it comes to creating solutions for my own needs.

I'm trying to create a db for a friend's business. I have two issues that I'm wrestling with. First is how to dynamically create a text box on a form.

I'm building a form that relates information between two tables (A, B). Table B is the source of the majority of the data on the form, while table A includes customer contact info (the tables are linked in a relationship).

I'm using a combo box to select customer information from table A. The cbx includes LastName, FirstName MI. and DateofBirth (in that arrangement). Hidden values include the customer ID (primary key) and date when the customer was entered into the db.

I want to dynamically generate a boilerplate with the customer's address and phone number right below the cbx. The information will be specifically used for this form and the current user. Any subsequent review of the data will be generated in a report that will automatically populate from both tables (I haven't created this report yet, though, so I may be posting again :) ).

I'm assuming the solution will be a vb code based on some event (After Update?), and will define the caption property. Any help on this one?

Hopefully, the second problem is easier. There is a checkbox on Table A which must be set to True. The box defines whether or not an insurance liability form has been completed before specific sales are completed (paint ball markers JFYI). This information is best stored on Table A (customer info) than on Table B (sales info) because one customer may buy several markers over a period of time.

I want to display the status of the checkbox on the form. I also want the user to be able to update Table A by using this checkbox. I found a workaround for this problem on another form where I used the tag property of the cbx and I created another textbox and an "Update" button which could update Table A based on the information in the second text box (does that make sense?).

However, that was a textbox, not a checkbox, so I'm not sure if it will work the same. Assuming it will work, and since there is still only one item that I must be able to change in Table A from this form, should I just do the same thing? Or, is there a more direct and efficient way to accomplish this?

Thanks in advance for any help offered.
Mar 31 '08 #1
2 6484
Zwoker
66
Hi,

Looking only at your first question:

Having a quick Google for creating objects in VBA for MS Access I found some code that works, but it seems that it can't be used to update the form you are running from... So perhaps this doesn't help you.

Does anyone know how to do this on the current form you have the code running in?

An alternative may be to have the text boxes already created on your form, but have the Visible property set to No until you need to display them.

Anyway, here is the code for what it is worth. It is assumed that the code is called from a form other than the one that the code references (test_form). I tried this (in MS Access 2003) and it worked fine.

Expand|Select|Wrap|Line Numbers
  1. Private Sub MakeATextBox()
  2.   ' Creates a text box of the name "tbxTest" using the control source "txtTest"
  3.   ' The text box is 1 in wide, 2 inches high, placed 0.5 inches from the
  4.   ' top and left of the detail
  5.  
  6.   Const TWIPS As Integer = 1440 ' text box dimensions are in twips
  7.   Dim ctl As Control
  8.   Dim intLeft As Integer
  9.   Dim intTop As Integer
  10.   Dim intWidth As Integer
  11.   Dim intHeight As Integer
  12.   intLeft = 0.5 * TWIPS
  13.   intTop = 0.5 * TWIPS
  14.   intWidth = 1 * TWIPS
  15.   intHeight = 2 * TWIPS
  16.  
  17.   DoCmd.OpenForm "test_form", acDesign
  18.   Set ctl = CreateControl("test_form", acTextBox, acDetail, , "txtDesc1", intLeft, intTop, intWidth, intHeight)
  19.  
  20.   ctl.Name = "tbxTest"
  21.   DoCmd.Close acForm, "test_form", acSaveYes
  22. End Sub
  23.  
  24. ' Call the code from where ever it is needed.
  25. MakeATextBox
Mar 31 '08 #2
I see what the code is trying to do, and it makes sense. I'll have to play with it a little bit tomorrow. I'm thinking the command should be able to generate the box on the same form using the 'Me' call, but I'll find out.

Also, I was unclear about how I was going to run this. The information box will already be in place on the form, but the information presented in it will be left blank until a selection is made from the combo box. I will definately try settig the visible property, though, as this may work very simply.

My major concern is whether or not vb can dynamically create the text in the same form (which still seems to be in question) and if it can do so based on the primary key data of a foreign table.

Thanks for the code- its a good place for me to start. If anyone can gather more info on this or the second question, I would still appreciate more help.
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Rathtap | last post by:
I want to write a C# application (lets call it Generator) that will receive an argument(patient account number) and dynamically generate a series of linked HTML files (claim information, payments,...
0
by: Avon | last post by:
Hi friends, I am very sorry for my not perfect English. I have one question, I am using David Bauer's DynamicControlsPlaceholder to dinamically generate controls and I am tryig to generate...
9
by: sashang | last post by:
Hi I'd like to use metaclasses to dynamically generate a class based on a parameter to the objects init function. For example: class MetaThing(type): def __init__(cls, name, bases, dict,...
1
by: firenet | last post by:
21 function js_reply_msg(node,g_id,u_id,par_id) 22 { 23 node.innerHTML="<FORM><TEXTAREA name=\"msg_con\"><\/TEXTAREA><br><INPUT type=\"submit\" value=\"reply\"><\/FORM>" 24 ...
1
by: Scott Zabolotzky | last post by:
I'm sure somebody has to have done this already but I can't find any good references. If I have an XML file with an associated XSD what is the best way to dynamically generate a web form with...
2
by: Steven C | last post by:
Hello: I'm trying to dynamically generate some labels for a form, and I can't seem to get it to work. The code is as follows. The first label is generated, but subsequent labels are not. Is...
7
by: kendu | last post by:
Is it possible to dynamically load a form from file? This form is just a .vb file and has not been added to the project during design time. Ken
4
by: high | last post by:
hi, im new to this platform, i have been creating a web page using MS Front page and i need to insert a text area to give the input and another text area to store that, <form...
10
by: phopman | last post by:
Hi there! Thanks for all the help so far. When my boss said I should be up to date as soon as possible, he meant last week. So I got a good rollicking when I came to work. Nice way to start my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.