Adding textbox to form with VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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.
 
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
 
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.
 
Back
Top