I´m using this statement using an integer variable (fol ) to do the search, but I get this error :
Run-Time error '3061'
too few parameters expected 1.
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = fol", dbOpenDynaset)
Thanks...
Printable View
I´m using this statement using an integer variable (fol ) to do the search, but I get this error :
Run-Time error '3061'
too few parameters expected 1.
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = fol", dbOpenDynaset)
Thanks...
If it's a string value it must have quotes around it...VB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = 'fol';", dbOpenDynaset)
Sorry, I misread!!...
try thisVB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = " & fol & ";", dbOpenDynaset)
String values don't require ' ' around them
do this
dim strSQL as string
strSQL = "SELECT * FROM Detfact WHERE Folio =" & " " & fol
Set RS = DB.OpenRecordset( strSQL , dbOpenDynaset)
The prior is for integer values only. If it is a string variable then
strSQL = "SELECT * FROM Detfact WHERE Folio =" & " " & "'" fol & "'"
Set RS = DB.OpenRecordset( strSQL, dbOpenDynaset)
Correction, I missed an &
The prior is for integer values only. If it is a string variable then
strSQL = "SELECT * FROM Detfact WHERE Folio =" & " " & "'" & fol & "'"
Set RS = DB.OpenRecordset( strSQL, dbOpenDynaset)
Don't know where you learned that mate but you do need quotes around string values in SQL, otherwise you get the error he described. Not only that but you contradicted yourself by including quotes anyway. I'd also like to point out you can edit posts, rather than making 2 correction posts.Quote:
Originally posted by TimJ
String values don't require ' ' around them
What the hell is that?!? It should be Folio = '" & fol & "';". I suggest you learn how to code before slagging me off.Quote:
Folio =" & " " & "'" & fol & "'"
Ignore all the bollocks he just gave you..if you want to get an integer value from a variable into an SQL statement, do this.If that variable contains a string, do this...VB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = " & fol & ";", dbOpenDynaset)If you just want a straight SQL statement with no variable interpolation to include a number do this...VB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = '" & fol & "';", dbOpenDynaset)To do the same but with strings, do this...VB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = 8;", dbOpenDynaset)And lastly, if you want to use Dates, put # instead of ' in all above examples and make sure it is in mm/dd/yy format.VB Code:
Set RS = DB.OpenRecordset("SELECT * FROM Detfact WHERE Folio = 'fol';", dbOpenDynaset)
ROFLMFAO :D
Easy now, Chris :)
Hey, he said I was wrong. If i were, then fine, but I ain't so :p