Passing parameters to a Query

B

Berny

Can anyone tell me if it is possible to pass the parameters from a form or
report to a Query?

I'm looking to pass the parameters to the query in a similar manner as using
the input box for passing filter parameters.

Is this possible?

Were can I look? What is it called? I haven't been able to find any
examples.

Any help would be greatly appreciated.
 
C

Cheryl Fischer

Yes, in Access you can pass a value in a form's control to a query. On the
"Criteria:" line of your query, simply enter:

Forms!MyFormName!MyControlName

hth,
 
B

Berny

Can this be done with vb?

Cheryl Fischer said:
Yes, in Access you can pass a value in a form's control to a query. On the
"Criteria:" line of your query, simply enter:

Forms!MyFormName!MyControlName

hth,
 
C

Cheryl Fischer

Yes, as long as the form containing the control to be referenced is open.
For example:

Dim strSQL as String

' Use this string if the criteria value is a string
strSQL = "SELECT * from MyTable where MyTable.MyField = " & chr(34) &
Forms!MyFormName!MyControlName & chr(34)

'Use this if the criteria value is a number
strSQL = "SELECT * from MyTable where MyTable.MyField = " &
Forms!MyFormName!MyControlName
 

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