Display query results in subform

thart21

Registered User.
Local time
Today, 11:29
Joined
Jun 18, 2002
Messages
236
If there's a post out there that addresses this, please point me in that direction as I've had no luck.

I have my queries listed in a table. On my form I have them listed in my combo box. The user selects the query they want and hits the command button "Run". I would like to show the selected query in a subform on the main form and then give the user the option of selecting another command button to export the query to Excel.

I thought it would be as simple as setting the recordsource of the subform to the query name in my combo box, but that doesn't work.

Current code to run query in separate window:

Command button "Run"
Private Sub Command9_Click()
DoCmd.OpenQuery Me.Combo2.Column(1)

Attempt at getting what I want:

Privat Sub_Command9_Click()
Forms!frmQuerySelection!sfrmQuery.Recordsource = Me.Combo2.Column(1)
or perhaps
sfrmQuery.Recordsource = Me.Combo2

Am I even close?

Thanks
 
i was actually just working on something similar, a subform recordsource dependant on user's input.

is the subform going to be running off of the same source object?

If that is the case, and you just want one dropdown box, what you can do is build the recordsource for each combo box option, then when the user selects it you have:

frmSubform.Form.RecordSource = "THE SQL VIEW INFORMATION FROM THE QUERY YOU BUILT"
frmSubform.Requery
 

Users who are viewing this thread

Back
Top Bottom