Linking same Form to different Queries? HowTo?

  • Thread starter Thread starter 555466
  • Start date Start date
5

555466

Problem:

- several Tables, which field etc structure is the same, only content varies
- only one Form for all Tables (same layout etc)
- Menu with buttons to control opening Form to fill in information to
certain Table

Q: how to tell to Form, which Query/Table it should be referring to ?

(by pushing Button1, Form should know to get the information from Table1
etc.)

Reason to have only one form, is simply the simplicity of updating the
Forms, when ever something is changed, no need to change all the Forms, just
one.

Thanks in advance
 
You could set the recordsource of the form through code when you press the
button. Or you could pass the record source as an OpenArgs parameter and have
the form's on open code set the proper record source for the form. Both of
these methods are UNTESTED.

DoCmd.OpenForm "YourFormName"
Forms("YourFormName").RecordSource = "YourTableOrQueryName"

or

DoCmd.OpenForm "YourFormName",,,,,,"YourTableOrQueryName"

And then in the OnLoad Event of the form

If Len(Me.OpenArgs & "") > 0 Then
Me.RecordSource = Me.OpenArgs
End If
 
Back
Top