Solved Data Type Mismatch in Delete Query SQL (1 Viewer)

LanaR

Member
Local time
Tomorrow, 00:02
Joined
May 20, 2021
Messages
113
The following SQL is throwing a 3464 Run time error Data type mismatch in criteria expression

Code:
    'SQL statment to delete exsiting record(s) relating to current wine
    StrSQL = "DELETE TBL_WineGrape.WineID, TBL_WineGrape.WineGrapeID " & _
            "FROM TBL_WineGrape " & _
            "WHERE (((TBL_WineGrape.WineID)= '" & [Text12] & "'));"

I'm referring to [Text12] in other SQL in other events, without issue. The only thing I can think of is that in this instance [Text12] is being populated by Left(OpenArgs, Len(OpenArgs) - 4) (yes [Text12] is holding the value I'm expecting) whilst in all other instance it is simply being populated by the raw OpenArgs. I can't for the life of me see where I've gone wrong
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:02
Joined
May 7, 2009
Messages
19,169
you probably need to translate [Text12] into a Tempvar.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:02
Joined
Jan 20, 2009
Messages
12,849
Debug.Print the value of StrSQL before you execute it and see what it saying.
 

LanaR

Member
Local time
Tomorrow, 00:02
Joined
May 20, 2021
Messages
113
So I'm guessing the issue was because [Text12] was being used as part of a WHERE clause. As in all other instances, it was simply providing a value to be inserted into a table.
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 00:02
Joined
Jan 20, 2009
Messages
12,849
So I'm guessing the issue was because [Text12] was being used as part of a WHERE clause.
You have concatenated Text12 into the SQL command so it should be fine. However I believe if you did a Debug.Print of Strsql you would find that there is nothing being inserted.

Hard to be sure without knowing more about your code but it may be that OpenArgs has only populated the Text property of Text12 but the Value property has not yet been updated when you are reading it.
 

Users who are viewing this thread

Top Bottom