Table???? Prompt

  • Thread starter Thread starter Isaac Sanchez
  • Start date Start date
I

Isaac Sanchez

Can it be done so that a form will prompt for
the table or query to be used to fill the data
fields of the form?

Isaac
 
Yes, use the result of the prompt to change the form property Record Source
and refresh the form. I assume you understand that the number of fields,
field names, etc. must match what's on your form. In other words, all of
your tables must have the same structure for this to work.
 
Thanks for the reply.
Each table will be EXACTLY the same!!
And how would I do that......
"use the result of the prompt to change the form property Record Source"
What would the code be and where do I have to put it?

Isaac
 
Let's say you have a control ComboBox1 with the list of the table names.
Using the combo box's After Update event:

Me.RecordSource = Me.ComboBox1
Me.Requery

This assumes that the form is bound to the table and the combobox is an
unbound control.

So start by creating a new form based on one of the tables (let the wizard
construct it for you). Go into design view of the form and create a combo
box control in the form header. Populate the combo box with the names of the
different tables. Then select [Event Procedure] in the combo box's After
Update Event, select the [...] button at the end of the line, and enter the
above two lines of code. Try it, you'll like it.

Isaac said:
Thanks for the reply.
Each table will be EXACTLY the same!!
And how would I do that......
"use the result of the prompt to change the form property Record Source"
What would the code be and where do I have to put it?

Isaac
Yes, use the result of the prompt to change the form property Record
Source
[quoted text clipped - 7 lines]
 
Thanks for the reply.
Each table will be EXACTLY the same!!

Then your database structure really should be reconsidered.

Storing data in tablenames, as you are doing, is VERY BAD DESIGN and
will get you into far more work than needed.

Consider having *ONE* big table, with an indexed field distinguishing
what are now separate tables. You can then use one form, and simply
filter it or base it on a Query selecting one set of data.

John W. Vinson[MVP]
 
Back
Top