Filter Main Form by Value on Subform

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

Guest

Is it possible to open a main form based on the value of a field in one of its subforms? I am trying to allow the user to enter a phone number in an unbound form. The mainform opens (using a macro) but limits the records displayed based on the phone number in the subform. The mainform is opening but no records appear.
 
Ralph said:
Is it possible to open a main form based on the value of a field in one
of its subforms? I am trying to allow the user to enter a phone number in
an unbound form. The mainform opens (using a macro) but limits the records
displayed based on the phone number in the subform. The mainform is
opening but no records appear.

You need a filter string that uses a sub-query.

Example assuming a PK field in main form named [ID] that is also the
linking field to the sub-form.


DoCmd.OpenForm "FormName",,,"[ID] In(SELECT ID FROM SubTable WHERE
[PhoneNumber] = '123-456-7890')"
 
Back
Top