I am using INSERT statement to execute the program. And the error has occured : "Data mismatch in criteria expression". I am checking my database but I could not find the error. Can you help me to fix the program.
I am appreciate for your help!!!!!
Printable View
I am using INSERT statement to execute the program. And the error has occured : "Data mismatch in criteria expression". I am checking my database but I could not find the error. Can you help me to fix the program.
I am appreciate for your help!!!!!
Well a quick look at the Proggy i did notice this...
Now the sample Excel sheet included, has a problem with some of those Ranges...Code:con.Execute "INSERT INTO tbl_item_detail VALUES ('" & rs("MaxField") + 1 & "','" & ws.Range("C" & i).Value & "','" & ws.Range("A" & i).Value & "','" & ws.Range("D" & i).Value & "','" & ws.Range("E" & i).Value & "','" & ws.Range("F" & i).Value & "','" & ws.Range("G" & i).Value & "','" & ws.Range("H" & i).Value & "','" & ws.Range("I" & i).Value & "','" & ws.Range("J" & i).Value & "','" & ws.Range("K" & i).Value & "','" & ws.Range("L" & i).Value & "','" & ws.Range("M" & i).Value & "','" & ws.Range("N" & i).Value & "','" & ws.Range("O" & i).Value & "','" & ws.Range("P" & i).Value & "','" & ws.Range("Q" & i).Value & "','" & ws.Range("R" & i).Value & "','" & ws.Range("S" & i).Value & "','" & ws.Range("T" & i).Value & "','" & ws.Range("U" & i).Value & "','" & ws.Range("V" & i).Value & "','" & ws.Range("W" & i).Value & "','" & ws.Range("X" & i).Value & "','" & ws.Range("Y" & i).Value & "','" & ws.Range("Z" & i).Value & "','" _
& ws.Range("AA" & i).Value & "','" & ws.Range("AB" & i).Value & "','" & ws.Range("AC" & i).Value & "','" & ws.Range("AD" & i).Value & "','" & ws.Range("AE" & i).Value & "','" & ws.Range("AF" & i).Value & "','" & "-1" & "','" & tenUser & "','" & NgayGioDangNhap & "')"
con1.Execute "INSERT INTO tbl_supplier(materialgroup,[desc]) VALUES ('" & ws.Range("A" & i).Value & "','" & ws.Range("B" & i).Value & "')"
IE: Column J, M, AC, AD (row 7) & AE (row 7) all have calculations in them and not Actual Values, These could be the source of your problem.....
Now the columns that have been defined as number in access need to receive a (Unformated) number before the insert will work.. So dont use ' on the numbers, because it designates Strings/Text.... Remove all number formatting including Currency/Weight/ Volume marks so that 2 413.98 cm3 is passed as 2413.98 <- NOTE: Not even a space is allowed.
Sort out these two problems and you should be able to complete the SQL insert command....