# Solved: VBA Access Problem with Requery



## dfriend846 (Aug 11, 2005)

I think I have found the answer to this: the subforms were actually named "Childxx" in the main form. When I changed the names of the objects the requery command works.

I want to learn Access VBA and am using work tasks as learning projects. For one I have an Excel dataset used as the datasource for Access. The data spans a number of years and each month I must report the month's activities in a number of categories. Using Access I first constructed queries to show the results using the Month() function allowing me to enter (e.g.) 8 for August. I then made a form with multiple tabs using subforms each showing a separate query. Everything works. I then put an option group on the main form for the month and am passing the value to the query using 
[Forms]![frm Review The Month's RTAs]![Frame118]
This works also as all queries work when I have the form open and a value for Frame118 chosen (allowed values 1-12 for the month of the year). The idea is that if I change the value in frame118 then the value sent to the queries should change and therefore the data. I can do this for the first subform on tab 1 with a requery command coming from frame118, on click but the commented requeries fail.

Private Sub Frame118_Click()
DoCmd.Requery ("sfrm qry1a NA RTAs In")
'DoCmd.Requery ("sfrm qry1b NA New Business RTAs In")
'DoCmd.Requery ("sfrm qry1c NA RTAs Out")
'DoCmd.Requery ("sfrm qry1d NA New Business RTAs Out")
'DoCmd.Requery ("sfrm qry1e NA RTAs Out Late")
'DoCmd.Requery ("sfrm qry1g NA Effective RTAs")

End Sub

I can't figure out why the first one works and the others do not. I am thinking it may have to do with the subforms being on tabs and perhaps not well enough specified in the requery command. Can anyone offer some suggestions?
Dennis


----------



## OBP (Mar 8, 2005)

Is there a Main Form?
If there is you may need to include it in the subforms name, unless the sub form is open and "current" Access VBA may not be able to find it, do you get any error messages when they fail?


----------

