Filter Main Form by Value on Subform

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.
 
R

Rick Brandt

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')"
 

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