Possible to open form and specify a table to use?

TimE

Registered User.
Local time
Yesterday, 17:36
Joined
May 17, 2005
Messages
55
Is it possible to open a form and have it use a certain table? Instead of going into the form properties and specifying the table there, can it be done using the docmd.open command? I have 2 identical tables that serve different purposes and based on what is enter in the lookup form would determine which table to use when the detail form opens.
 
You should be able to set the recordsource of the form on opening if you do it in the On Load event of the form. In the event where you are opening the form, set a public string variable (declare it in a standard, not form, module) and assign it the SQL string when you click. Then, use the On Load event to assign it.

So, like this.

In Standard Module Declarations Section:
Code:
Public strSQL As String

In the On Load event do this:

Code:
Me.Recordsource = strSQL
Me.Requery
 

Users who are viewing this thread

Back
Top Bottom