military donut
asked on
sql VBA UPDATE too few parameters
Hello,
I have the below statement that I tried 2 different ways. don't know what I have wrong?
the first one gives too few parameters and the second says It can't find the table
This is the debug result for each
UPDATE tblUser SET Checked = -1 WHERE FName = 34
UPDATE tblUser SET [Checked] = -1 WHERE [FName] = 34
even for the 3rd way I get a syntax error:
I have the below statement that I tried 2 different ways. don't know what I have wrong?
the first one gives too few parameters and the second says It can't find the table
strSQL = "UPDATE tblUser " _
& "SET Checked = -1" _
& " WHERE FName = " & Me.FName
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError
strSQL = "UPDATE tblUser " & _
"SET [Checked] = -1 " & " " & _
"WHERE [FName] = " & Me.FName
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError
This is the debug result for each
UPDATE tblUser SET Checked = -1 WHERE FName = 34
UPDATE tblUser SET [Checked] = -1 WHERE [FName] = 34
even for the 3rd way I get a syntax error:
strSQL = "UPDATE tblUser " _
& "SET Checked = -1" _
& " UserName = " & Me.APIUserName1 _
& " WHERE FName = " & Me.FName
Debug.Print strSQL
CurrentDb.Execute strSQL, dbFailOnError
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
good catch, gustav
and the 3rd example needs delimiters around the values to compare if they are strings too (in addition to needing a comma)
and the 3rd example needs delimiters around the values to compare if they are strings too (in addition to needing a comma)
ASKER
Thanks!
Gives me
too few parameters....expected 1
Gives me
too few parameters....expected 1
what is the data type of FName in the table?
what is the data type of Checked?
what is the data type of Checked?
ASKER
text
ASKER
Updates is
Yes/No (true/false)
sorry forgot that one..
Yes/No (true/false)
sorry forgot that one..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
too few parameterstypically means that a field is missing or misspelled.
/gustav
ASKER
Ahhh....crystal
Gotcha...mixed up the fields from the form and the table....didnt' change the statement
plus I needed the single quotes as Gustav Brock said....
strSQL2 = "UPDATE tblUser " _
& "SET Updated = -1" _
& ", UserName = '" & Me.APIUserName1 & "'" _
& " WHERE FName = '" & Me.FName & "'"
Debug.Print strSQL2
CurrentDb.Execute strSQL2, dbFailOnError
Thanks once again!
Gotcha...mixed up the fields from the form and the table....didnt' change the statement
plus I needed the single quotes as Gustav Brock said....
strSQL2 = "UPDATE tblUser " _
& "SET Updated = -1" _
& ", UserName = '" & Me.APIUserName1 & "'" _
& " WHERE FName = '" & Me.FName & "'"
Debug.Print strSQL2
CurrentDb.Execute strSQL2, dbFailOnError
Thanks once again!
you're welcome, Ernest ~ happy to help
perhaps tblUser isn't the right name of the table?