Open SubForm based on different queries

esskaykay

Registered User.
Local time
Today, 21:40
Joined
Mar 8, 2003
Messages
267
I’m looking for a way to open a SubForm from different command buttons on my MasterForm where Button-A opens the SubForm with the RecordSource = Query-A, Button-B opens the same form based on Query-B. Query-A is a simple select query. Query-B is basically the same query with the addition of a Criteria [Enter Permit Number] parameter.

Any suggestions?

Thanks,
SKK
 
I think the quickest way to do this is to make two identical subforms which have the different queries, then set the source object of the subform on the Master form like this:

Click button A code:
Me.mySubFormName.SourceObject = "subFormA"

Click button B code:
Me.mySubFormName.SourceObject = "subFormB"

Regards
Melt
 
Try in the on click event, something like;

Code:
Me!FRM_MySubform.Form.RecordSource = "SQL statement for query "
Me!FRM_MySubform.Form.Requery

Also have a look at the attached.
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom