Hi,
I have a data type mismatch in criteria expression with the following code:
All the fields have Text data type (FoodEx1_cd and Nat_cd in table mapping and source fields of ListSelectedNatcd (Listbox) and FE1_cd (unbound text box).
I thought that I made a mistake in the Where-clause and tried this:
But this gave the error Syntax error in string query expression 'Mapping.Nat_cd='0'.
And I tried:
But this resulted again in a data type mismatch.

I hope someone can help me!
Thank you in advance,
Tep
I have a data type mismatch in criteria expression with the following code:
Code:
Dim SQL As String
Dim db As DAO.Database
Dim varItem As Variant
Set db = CurrentDb()
Dim i As Integer
For i = 0 To Me.ListSelectedNatcd.ListCount - 1
Me.ListSelectedNatcd.Selected(i) = True
Next i
For Each varItem In Me.ListSelectedNatcd.ItemsSelected
SQL = "UPDATE Mapping " & _
"SET Mapping.FoodEx1_cd = '" & Me.FE1_cd.Value & "' " & _
"WHERE Mapping.Nat_cd = " & varItem
DoCmd.RunSQL SQL
Next varItem
All the fields have Text data type (FoodEx1_cd and Nat_cd in table mapping and source fields of ListSelectedNatcd (Listbox) and FE1_cd (unbound text box).
I thought that I made a mistake in the Where-clause and tried this:
Code:
"WHERE Mapping.Nat_cd = '" & varItem '
And I tried:
Code:
"WHERE Mapping.Nat_cd = " & CStr(varItem)

I hope someone can help me!
Thank you in advance,
Tep