10-25-2000, 08:14 AM
The user enters a specific record they want to open, which I assign to the variable, ver1. I want only that record to be pulled. I cannot figure out how to use the variable in the sql question though. This is what I tried:
Set rs = db.OpenRecordset("SELECT testkey.* From testkey WHERE TestID= ver1")
I have played with moving the quotes and using & but nothing seems to work. Any ideas or suggestions?? thanks.
10-25-2000, 08:39 AM
Dim strSQL as String
strSQL = "SELECT * From testkey WHERE TestID = " & ver1
Set rs = db.OpenRecordset(strSQL)
If TestId is a string use
= '" & ver1 & "'"
10-25-2000, 08:47 AM
I tried that and got: "run time error 3061. Too few parameters. Expected 1."
Testid is my primary key field in the table testkey. Basically, the user should be able to enter a testid, and the program should open that particular record from the testkey table...
I also tried it this way:
strSQL = "SELECT * From testkey WHERE TestID = ' & ver1 '"
and got a runtime error 3021, no current record. but i set a breakpoint and tested ver1, and it does hold the exact same value as what is in the table.
10-25-2000, 10:05 AM
There would appear to be something wrong with your variable ver1.
Try putting the value your looking for directly in the SQL string
"SELECT * FROM TestKey WHERE TestId = 44"