Subform Query

jamphan

Registered User.
Local time
Today, 10:14
Joined
Dec 28, 2004
Messages
143
I need to have a subform query embedded in my main form that when the user selects an item from a drop down box it will display the query results in the sub form. I have my query set up to work off of this drop down box I just can't get it to update on the subform when selected. Any ideas?
 
Mave you tried to requery the SubForm in the AfterUpdate event of the cbo? Me.SubFormControl.Form.Requery
 
I just tried but it gave an error. Where do I need to include that verbiage and is that the exact verbiage I need to use?
 
You need to replace the Bold name with the name of your SubFormControl.
Me.SubFormControl.Form.Requery

And as I said earlier, put the code in the AfterUpdate event of the ComboBox (cbo)
 
Something isn't clicking, probably me. It will not update. Should the code go in Expression Builder or Code builder in the After Update box of my list box? Do I need to include anything else in my query. Right now the query is dependent on what is in the list box on my form but will not run until it is activated.
 
It should go in the Code Builder. You are now referring to your control as a List Box when you started calling it a drop down box which I took to mean a ComboBox. Which is it?
 
It is a combo box. Sorry for the confusion. My code is in the code builder with the name of my subform. It does not update after I make a selection. Could it be something in the query?
 
Post the code from Private Sub --- thru End Sub

And post the SQL for the query also please.
 
SQL
SELECT tblMain.Date, tblMain.Region, tblMain.Contact, tblMain.Discussion
FROM tblMain
WHERE ((([Forms]![frmMnForm]![Region])=True))
GROUP BY tblMain.Date, tblMain.Region, tblMain.Contact, tblMain.Discussion;


Private Sub Combo2_AfterUpdate()
Me.RegHistSub.Form.Requery
End Sub

My subform is renamed RegHistSub
 
The code in the AfterUpdate event looks good but I don't see anything in the SQL that points to the Combo2 control where the requery would make any difference.
 
What do I need to put in the query to make it point to that?
 
Nevermind. I got it. Thanks for all of your help and I apologize for being so slow today!
 
Is that the SQL for the ComboBox or the SubForm? I need to see the SQL for both so post the other please.
 
Outstanding! Sometimes it is just a matter of asking enough questions. Glad you got it working.!
 

Users who are viewing this thread

Back
Top Bottom