SQL Update code problem.

Faray

Registered User.
Local time
Today, 02:32
Joined
Jul 23, 2009
Messages
16
Hello,
I am having a problem with my SQL update statement, maybe someone can tell me what i have wrong.

Here it is:
Code:
strSQL = "UPDATE [Printtable] SET [ReprintNum] = '" & rp & "' WHERE [SerialNum] = '" & SNsearch & "'"
CurrentDb.Execute (strSQL)

All on one line

I keep getting the error Run-time error '3464'
Data type mismatch in criteria expression.

rp is a value from a textbox, and snsearch is also a textbox value, if that makes a difference. Both are numbers in a table.

Thank you.
 
Here it is:
Code:
strSQL = "UPDATE [Printtable] SET [ReprintNum] = '" & rp & "' WHERE [SerialNum] = '" & SNsearch & "'"
CurrentDb.Execute (strSQL)

All on one line

I keep getting the error Run-time error '3464'
Data type mismatch in criteria expression.
This means your using a text as a number or vice versa....

rp is a value from a textbox, and snsearch is also a textbox value, if that makes a difference. Both are numbers in a table.
Yes so... your using the number as a string...
If you enclose anything with ' ' or " " , then that is a string.
Your enclosing both numbers with ' ', making them a string in the query and comparing that to a number = The problem.

Remove the ' ' around each field to resolve your error.

FYI
Number field: [Num] = " & SNsearch & ""
Date field: [StartDate] = #" & SNsearch & "#"
Text field: [Name] = '" & SNsearch & "'"

Happy coding !
 
Thank you, that solved the problem :)
 

Users who are viewing this thread

Back
Top Bottom