Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using form object in query 1

Status
Not open for further replies.
Feb 2, 2005
42
US
Am new to Microsoft Access project...please bear with me...

I'm attempting to reference a form object in a query that's used in determining a data set for a subform. I understand that using the Forms!MyForm!MyCotrol syntax will not work since sql does not recognize this format.

From reading a few previous threads, it seems that I will instead have to declare a variable to receive the value of MyControl, and then have that value passed to the query.

My first question is how do I declare a variable to receive the value of MyControl? Also, will the variable change each time the value of MyControl is altered?

Secondly, how do I pass the variable which holds the value of MyControl to the query?

Thanks in advance for any assistance!
 
In your form's recordsource property:
Select * From MyTable Where MyTableField = ?

Yes, put a "?" in place of where you want some value to be at.

In the form's Input Parameters, place your control which you want to be passed on to the "?".

Input Parameters: Forms!MyForm!MyControl

The "?" is part of SQL server query syntax.
 
Hello, I might be even newer than the original poster was to Access. How do you modify the imput parameters for a form to enter Forms!MyForm!MyControl? Thanks for your time.

Nick Ruiz
CO-OP Intern, PPL Electric Utilities
Webmaster, DealMerchant.net
 
In a form, switch to DESIGN VIEW, display PROPERTIES, then at the bottom part of the properties, you will find the INPUT PARAMETERS.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top