Run a query in a subform based on a value in the main form.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm sure this is possible but am racking my head on how to accomplish this.
I have a mainform that is getting it's values from a table, pretty standard
stuff. I also have a subform where it's record source is a query that I would
like to be based on a value in the main form. The query does work as I have
tested it. I tried various methods but all I get is a blank subform and no
records. Does anyone know how to accomplish this? Once this is accomplished
is there a way to have the qeury run as you scroll through the records using
the record selectors on the main form?

Many Thanks....
 
The easiest way to accomplish this would be to use the LinkMasterfields and
LinkChildFields of the Subform control to specify the related fields in the
main and subform. Then Access will do the requery for you. Otherwise, you
would simply need to use the Current event of the main form to requery the
subform:

me.sfrmMySub.requery

where sfrmMySub is the name of the subform control on the main form.

Note that you would also need to requery the subform control using the
AfterUpdate of the linking field (another freebie if you use the linking
field properties).

I can't say why your current query/subform isn't working since you didn't
post any code. Post the SQL for your query and describe what controls/fields
you have on the main form. You should probably try the requery first.
 
Back
Top