Solved

ERROR: 2147217913

Posted on 2004-04-07
3
402 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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