How can I reference an unbound form variable in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to use an unbound form variable in a query as a parameter, please tell
me how to do it?
 
In the Criteria row of your query, you can refer to Textbox2 on Form1 like
this:
[Forms].[Form1].[Textbox2]
 
Abdul,

Just in case you actually meant to say "variable"; you cannot refer to a
variable directly in SQL. The only way to refer to a variable is by using a
custom function. For example, if you have a variable called intMyVariable,
you'd have to create a function like so:
Public Function GiveMeMyVariable() As Integer
GiveMeMyVariable = intMyVariable
End Function

Then you can refer to the function in SL like so:
SELECT Field1, GiveMeMyVariable FROM myTable

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top