Type mismatch Error

  • Thread starter Thread starter subbu
  • Start date Start date
S

subbu

Hi,
I am using the update statement to update the record in
the table.I am getting the above error during the query
formation step.The same way i did update another
table.what is the reason for the error.I am pasting the
statement here

ssql = UPDATE Request SET Req_IDN =" + strNumber + "
WHERE Req_IDN =" & 0

subbu
 
If the error has the word "type" in it as being a part of the problem, you
should probably tell us what type your field is. Since you are using "str",
I assume it is a string data type. Also, there was no beginning
double-quote. If Req_IDN is string then try:

ssql = "UPDATE Request SET Req_IDN =""" & strNumber & """ WHERE Req_IDN ='0'
"

If the field is numeric:
ssql = "UPDATE Request SET Req_IDN =" & strNumber & " WHERE Req_IDN =0 "
 
Hi,
I am using the update statement to update the record in
the table.I am getting the above error during the query
formation step.The same way i did update another
table.what is the reason for the error.I am pasting the
statement here

ssql = UPDATE Request SET Req_IDN =" + strNumber + "
WHERE Req_IDN =" & 0

The problem here is that you are mixing VBA and SQL - two different
languages which do not understand one another's syntax. What you
*want* to be doing is constructing a String ssql by concatenating
together string constants and string variables. If Req_IDN is a
Numeric field, the correct syntax would be

ssql = "UPDATE Request SET Req_IDN =" & strNumber & _
" WHERE Req_IDN = 0;"

This will concatenate three string values together:
a string constant "UPDATE Request SET Req_IDN =", a string variable
strNumber, and another string constant " WHERE Req_IDN = 0;"

If strNumber contains "123", the resulting value of ssql will be

"UPDATE Request SET Req_IDN =123 WHERE Req_IDN = 0;"

which when executed willin fact perform an update query.
 
Back
Top