Click to See Complete Forum and Search --> : passing value from text box to SQL


John Watson
May 27th, 1999, 05:24 PM
I'm using VB6 and an Access database. I have two text boxes. I want the user to be able to enter a low monetary amount in one text box and a high one in the other, and then pass these values to a recordset's SQL statement, as in ..."WHERE x BETWEEN '600' AND '900'. I can't use variables to pass these values to the SQL statement because Access can't read the variables. Is there any way of doing this? Any help is appreciated.

Rufus
May 27th, 1999, 06:50 PM
Hi John:

I hope the other things worked for you. For var's in SQL, do it like this:

strSQL="SELECT ### FROM ### WHERE TABLE.FIELD > " & varName & " AND < " & anotherVarName

Don't forget to put the spaces at the start or end of the strings so your statment does not run together.

Rufus
May 27th, 1999, 06:54 PM
Correction:

strSQL="SELECT ### FROM ### WHERE TABLE.FIELD > " & varName & " AND TABLE.FIELD < " & anotherVarName

Sorry.