Control Button to Run Query Off of a Form

  • Thread starter Thread starter Uninvisible
  • Start date Start date
U

Uninvisible

I have a form, which is really a form/subform:

form: File information
subform: Contact information

(1:many relationship -- 1 file can have many contacts)

When on the subform, I want to execute a query from a control button
which will bring up the many transactions associated with the Contact.
I can run the query, but it shows the results for each contact, not the
one appearing on the subform. How do I get the control button to
reference the specific contact ID so that when the query runs, it only
shows the contact's transactions.
 
The query's select statement need to have a where clause that reads from the
form:

Select * From MyTable Where CustomerID =
Forms!MyForm!MySubformControlName.Form!txtContactID

or in code:

"Select * From MyTable Where CustomerID =" &
Forms!MyForm!MySubformControlName.Form!txtContactID
 
Back
Top