Click button show results in subform

M

mccloud

I have a form that has 3 cmd buttons. Each cmd button opens and runs a
query. I would like to have a sub form in the main form that will show
the results of the query that was selected. So that on click the query
results will open in the subfrom window How do I do this?
 
G

George Nicholson

On the click event for each button, set the SourceObject property of the
subform control to the name of your query:

for cmdButton1_Click:
Me.sctlSubformControl.SourceObject = "qryMyQuery1"

for cmdButton2_Click:
Me.sctlSubformControl.SourceObject = "qryMyQuery2"


HTH,
George Nicholson

Remove 'Junk' from return address.
 
M

mccloud

Thanks for the reply but I'm still not clear on one part. The
".sctlSubformcontrol." What should this be? The subform name? Sorry but I'm
new!
 
G

George Nicholson

Me.sctlSubformControl.SourceObject = "qryMyQuery1"

where sctlSubformControl is the name of the control created to contain a
subform. SourceObject would normally be where you specify which form to show
as a subform within that control, but in this case there is no "form" per
se, just your query output.
 

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