Solved

ERROR: 2147217913

Posted on 2004-04-07
3
396 Views
Last Modified: 2013-12-25
I get the error datatype mismatch in criteria expression with my Insert query, which is as follows:

SQLInsert = "insert into Participation([Term Code], [Course Code], [Player ID])"
                 SQLInsert = SQLInsert & " values('" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 8) & "', '" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 9) & "', '" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 10) & "')"
                 objConn.Execute SQLInsert

in the immediate window, this is what ?SQLInsert gives;

insert into Participation([Term Code], [Course Code], [Player ID]) values('1910', 'AU2004', 'CU1358')

Which works fine in MsAccess, which is my back-end.

I have checked datatype in acess and its all good, also the exact query works on a different program for the same databse.

Please help!!!!
0
Comment
Question by:claracruz
  • 2
3 Comments
 
LVL 8

Expert Comment

by:bramsquad
ID: 10778748
are you sure your SQL query is correct?   this would be the format i would use


INSERT INTO Participation
SELECT
FROM YourTable
WHERE (((YourTable.[Term Code])='1910') AND ((YourTable.[Course Code])='AU2004') AND ((YourTable.[Player ID])='CU1358'));

~b

0
 
LVL 8

Expert Comment

by:bramsquad
ID: 10778759
nevermind what i just put, i read that q incorrect.......brb
0
 
LVL 18

Accepted Solution

by:
Sethi earned 500 total points
ID: 10780205
Type mismatch smpley points to the fact that you are inserting a string in a numeric column. Please check whether any of the columns is a numeric data type. Assuming that [Term Code] is a numeric one then this is how the query should look:
insert into Participation([Term Code], [Course Code], [Player ID]) values(1910, 'AU2004', 'CU1358')

You have to remove the single quotes from your SQL statement:

SQLInsert = "insert into Participation([Term Code], [Course Code], [Player ID])"
                 SQLInsert = SQLInsert & " values(" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 8) & ", '" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 9) & "', '" & frm_input.MsData.TextMatrix(frm_input.MsData.Row, 10) & "')"
                 objConn.Execute SQLInsert


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question