Datatype Mismatch (1 Viewer)

abbaddon223

Registered User.
Local time
Yesterday, 17:39
Joined
Mar 13, 2010
Messages
162
Hi,

I have the following SQL code running via VBA. I keep getting a datatype mismatch error, howevr the field I am referencing, and using as the qualifyer to update the record is Number.

Any help greatly appreciated!!!!

Dim Ref As String
Ref = Forms!Frm_WB_Login.Form!Frm_Callbacks_Due![callback_id].Value

Dim MySQL As String

MySQL = "UPDATE vicidial_callbacks SET vicidial_callbacks.status = 'INACTIVE' "
MySQL = MySQL & "WHERE vicidial_callbacks.callback_id = '" & Ref & "';"

DoCmd.RunSQL MySQL
 

namliam

The Mailman - AWF VIP
Local time
Today, 02:39
Joined
Aug 11, 2003
Messages
11,695
perhaps you should remove the ' around the ref in the SQL?
Instead of
MySQL = MySQL & "WHERE vicidial_callbacks.callback_id = '" & Ref & "';"
...
MySQL = MySQL & "WHERE vicidial_callbacks.callback_id = " & Ref & ";"
 

pr2-eugin

Super Moderator
Local time
Today, 01:39
Joined
Nov 30, 2011
Messages
8,494
If it is Number why have you declared it as String?
Code:
Dim [COLOR=Red][B]Ref As Long[/B][/COLOR]
Ref = Forms!Frm_WB_Login.Form!Frm_Callbacks_Due![callback_id]

Dim MySQL As String

MySQL = "UPDATE vicidial_callbacks SET vicidial_callbacks.status = 'INACTIVE' "
MySQL = MySQL & "WHERE vicidial_callbacks.callback_id =[COLOR=Red][B] " & Ref[/B][/COLOR]

DoCmd.RunSQL MySQL
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:39
Joined
Jan 23, 2006
Messages
15,393
It appears that Ref is a string. And that callback_id is number ----???

OOops: I see others have posted while I was typing.
 

abbaddon223

Registered User.
Local time
Yesterday, 17:39
Joined
Mar 13, 2010
Messages
162
Hi all,

Thank you for your kind responses - I've now got this working with your help!!

Thanks!
 

Users who are viewing this thread

Top Bottom