Hi

I have the following code which generates an error 'Data Type mismatch in criteria expression'

The purpose of the code is to write a value to a database at a specific row.

Dim IntSid As String
        Dim Sid As String
        Dim I As Integer
        
        IntSid = Me.TTIn.Text
        Sid = Me.SessionIDTextBox.Text
        I = CInt(Val(Sid))


        Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        IntSid & "' WHERE SessionId = '" & _
        I & " ' "

Recommended Answers

All 3 Replies

It looks like you never declared the datatype of loSQL.

It looks like you never declared the datatype of loSQL.

Hi

I got it to work the problem was the single quote around the variable I which is an Integer and not a String

My original SQL statement was

Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        IntSid & "' WHERE SessionId = '" & _
        I & " ' "

This should have been

Dim loSQL = "UPDATE tblSession SET TTout = '" & _
        Me.TTIn.Text & "'WHERE SessionId = " & _
        I & " "

ViRi

thanx for self learning, that really helps a lot.

commented: I agree :) +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.