Linking same Form to different Queries? HowTo?

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
 
J

John Spencer (MVP)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top