How to pass parameter to Query?

  • Thread starter Thread starter TA
  • Start date Start date
T

TA

Dear all,
I create a query, I want to take the value from a form
into query. How can I do that?
Like:
SELECT * from dbo_agency
WHERE agency.site = Me.cbo1

Thanks in advance,
TA
 
Dear TA:

The reference to a control on a form is:

[Forms]![Form Name]![Control Name]

Replace Me.cbo1 with the above, substituting the actual name of your
form and control.

For this to work, the form MUST be open at the time the query is run.
It is therefore very common to have the query be opened by some event
of that very form, such as clicking a command button.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Close, but you can't use Me. You need to fully specify the object. Me will
only work within a form or report.

SELECT * from dbo_agency
WHERE agency.site = FORMS!YourFormName!cbo1
 
Dear all,
I create a query, I want to take the value from a form
into query. How can I do that?
Like:
SELECT * from dbo_agency
WHERE agency.site = Me.cbo1

WHERE agency.site = [Forms]![NameOfForm]![cbo1]
 
Dear all,
It is working wonderful.
Again, I want to say thank you to all of you help me out
and step by step to finished my project using MS Access
for the first time in my life. Thanks to Microsoft have
this wonderful this webpage forum. It is very helpful.
Best Regards,
TA
 
Back
Top