Refresh Query using subform.....

sohailcdc

Registered User.
Local time
Today, 12:01
Joined
Sep 25, 2012
Messages
55
Hi there
I using combo box as input to run the query and to show the result on the on the form, using subform feature (not sure correct approach)
The only problem, when I select the value from using combo box the values on the subform does not change automatically even after pressing the run query button (code below), therefore, every time, i need to press F5 function button

I am not sure, I am doing right as I am closing DoCmd command to close the query, otherwise, Access Open Query Separately..... (which i don't want as I need result on the form)

Thanks in advance

Following are the code
Private Sub Yearlisting_Click()
On Error GoTo Err_Yearlisting_Click

Dim stDocName As String

stDocName = "AddNewYearQuery"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.Close
Exit_Yearlisting_Click:
Exit Sub

Err_Yearlisting_Click:
MsgBox Err.Description
Resume Exit_Yearlisting_Click

End Sub
 
You need to requery the subform, (put in the below code after you have run query for the subform).
What is the Record Source for the subform, show it, (it doesn't look right the way you do it).
You can use the after update event for the combo box, instead of having an extra button.
And right setup, you don't need DoCmd.
Code:
...
Me.[SubformName].Requery
....
 
Last edited:
Thanks and be happy always
Now, it works perfectly
 

Users who are viewing this thread

Back
Top Bottom