Adding textbox to form with VBA

B

Bill

Is it possible with VBA to add a new text box to an existing form, and then
extract data from a specific existing record to put into the new textbox? If
so, can you direct me to some good examples (in "Access 2003 Inside Out", if
possible)?

Thanks.

Bill Schaupp
 
A

Allen Browne

You can add a text box to a form only in design view. See help on
CreateControl().

Note that this does not work if you ever need to create an MDE, so you mind
find it better to add the text box now, and set its Visible property to show
it when needed.

To extract the data from the table to put into the text box, use DLookup().
Explanation:
Getting a value from a table: DLookup()
at:
http://members.iinet.net.au/~allenbrowne/casu-07.html
 
G

Geof Wyght

Bill,
Yes, it is possible to add controls to a form via VBA but
I would recommend that you create a textbox, bind it if
you can, hide it, then make it visible when you want to.
Geof Wyght.
 
B

Bill

Geof,

I am trying to create a flexible form that adds textboxes as required based
on a specific user's combo box selections. There is no telling beforehand
how many textboxes will be required.

My ultimate goal is to create some textboxes on the form with the combo
boxes showing information from existing records, and some other textboxes to
input new information.

Does this sound feasible, or is there a better solution?

Thanks

Bill
 
G

Geof Wyght

Bill,
I had to do something like this. In the end, I decided to
give my users a healthy maximum number of text boxes, hide
most of them and then show them when needed.
Geof Wyght.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top