Control Button to Run Query Off of a Form

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

Arvin Meyer [MVP]

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
 

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