Requery Subform/Query

G

Guest

I have a Main (unbound) form that has an option box. [All, New, etc...) The
thought is to allow the user to select from these options, and return the
applicable records. (With each selection, the underlying query's SQL is
changed) Everything works fine except when I try to requery the subform. I
works when you flip the form into & outof design view, but not on the requery
command.

DoCmd. Requery "Control"

"Control is the name of the sub form" I've tried the Me!Subform!Control and
all from the Access Web site, but no luck. I know this is something simple,
but it seems to be getting the better of me. Any advice would be greatly
appreciated.
 
M

Marshall Barton

nFaux said:
I have a Main (unbound) form that has an option box. [All, New, etc...) The
thought is to allow the user to select from these options, and return the
applicable records. (With each selection, the underlying query's SQL is
changed) Everything works fine except when I try to requery the subform. I
works when you flip the form into & outof design view, but not on the requery
command.

DoCmd. Requery "Control"

"Control is the name of the sub form" I've tried the Me!Subform!Control and
all from the Access Web site, but no luck. I know this is something simple,
but it seems to be getting the better of me. Any advice would be greatly
appreciated.


DoCmd is not all that clear on which object you want it to
operate on. Use this kind of reference instead:

Me.subformconrol.Form.Requery

Note that the name of the form displayed in the subform
control is irrelevant.

Instead of manipulating a query's SQL property, it would be
simpler/easier/more efficient to just set the subform's
record source property:

Me.subformconrol.Form.RecordSource = strSQL

If you do it this way, the Requery is automatic, so no
further code is needed.
 

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