Re: Access 2003 Form error
try putting the value of your variable into the SQL, instead of the variable name ;)
VB Code:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = " & stNum
Re: Access 2003 Form error
if stNum is a string, you'd need to enclose it within single quotes. This assumes the Comments field is text.
VB Code:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = '" & stNum & "'"
Otherwise dim it as an integer. You may also want to pass the value in as a variable to the sub rather than hardcoding it, or get it some other way (InputBox, Form, etc).
Your error could also occur if you haven't declared rs somewhere else at at least module level.
Re: Access 2003 Form error
Quote:
Originally Posted by si_the_geek
try putting the value of your variable into the SQL, instead of the variable name ;)
VB Code:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = " & stNum
Now I get:
Data Type Mismatch in criteria expression
Re: Access 2003 Form error
You know what this value never changes, so can't I put
VB Code:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = 25 "
Re: Access 2003 Form error
"Data Type Mismatch" means that (like in VB) you haven't used the right data type for something, and as salvelinus thought your Comments field appears to be a string, so you must use quotes, ie:
VB Code:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = '" & stNum & "'"
'or:
sSQL = "SELECT * FROM SATETRAINING WHERE Comments = '25' "