View Full Version : Use a generic form to open different tables at different times


Bohlayah
03-01-2001, 05:56 AM
Hi all,
Don't know if anyone can help on this...

I have designed a generic form that will satisfactorily display data from various tables at different times if I change 'Record Source'. (As you'd expect). However I'd like the form to be based on a table that is selected by the user. Preferably by pressing a command button. I have about 100 tables containing similar data but I don't want to create 100 froms for each one...it seems a waste.

Appreciate any ideas and suggestions,
TimO

llkhoutx
03-01-2001, 07:16 AM
You're getting it!

Have a form with a combo box by which the user selects the table (form) he wants to utilize.

On AfterUpdate or Onclick (of a button), open your generic form in hidden view, set the record source to the required table, and then open the form in normal view.

Bohlayah
03-02-2001, 06:27 AM
Cheers llkhoutx

You know when you ask a question and then you work out the answer?...

I ended up using this code after a button click.

Dim DocName As String
Dim LinkCriteria As String

DocName = "frm***"
DoCmd.Close acForm, "frm***", acSaveYes
DoCmd.OpenForm DocName, , , LinkCriteria, , acHidden
Forms!frm***.RecordSource = "qry***"
DoCmd.OpenForm DocName, , , LinkCriteria

Thanks for taking the time to reply,
TimO

[This message has been edited by Bohlayah (edited 03-02-2001).]