A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Control Button to Run Query Off of a Form



 
 
Thread Tools Display Modes
  #1  
Old December 13th, 2006, 06:58 PM posted to microsoft.public.access.forms
Uninvisible
external usenet poster
 
Posts: 9
Default Control Button to Run Query Off of a Form

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.

  #2  
Old December 14th, 2006, 03:23 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Control Button to Run Query Off of a Form

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!txtContactI D

or in code:

"Select * From MyTable Where CustomerID =" &
Forms!MyForm!MySubformControlName.Form!txtContactI D
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"Uninvisible" wrote in message
oups.com...
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.



  #3  
Old December 14th, 2006, 09:03 PM posted to microsoft.public.access.forms
Uninvisible
external usenet poster
 
Posts: 9
Default Control Button to Run Query Off of a Form

Works perfectly.

Thank you Arvin.

Arvin Meyer [MVP] wrote:
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!txtContactI D

or in code:

"Select * From MyTable Where CustomerID =" &
Forms!MyForm!MySubformControlName.Form!txtContactI D
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"Uninvisible" wrote in message
oups.com...
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.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:10 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.