Solved

Run-time error 13 type mismatch

Posted on 2013-01-15
10
612 Views
Last Modified: 2013-01-17
Getting the error Run-time error 13 type mismatch on the following line of code

Set CBEDSRst = CurrentDb.OpenRecordset("Select Distinct RecType, CBEDSCourse from [" & TblNmStr & "] WHERE RecType='C' and CrsType='" & CTypeArr(CTypeLpCnt) & "' " & PTCritArr(PTypeLpCnt))
0
Comment
Question by:needhelpfast569
  • 4
  • 3
  • 3
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38780896
what is the Data Type of field CrsType ?

if number

try this

Set CBEDSRst = CurrentDb.OpenRecordset("Select Distinct RecType, CBEDSCourse from [" & TblNmStr & "] WHERE RecType='C' and CrsType=" & CTypeArr(CTypeLpCnt) & " & PTCritArr(PTypeLpCnt))

or this

Set CBEDSRst = CurrentDb.OpenRecordset("Select Distinct RecType, CBEDSCourse from [" & TblNmStr & "] WHERE RecType='C' and CrsType=" & CTypeArr(CTypeLpCnt)  & PTCritArr(PTypeLpCnt))

what does the function "CTypeArr" do ?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38780903
Try added a debug .print to write your query string to the immediate window.  Is the query string what you are expecting?

If not, copy and paste it in your next comment.

Also, what is the datatype of the CrsType field?
And is TblNmStr a string variable or the name of an actual table?

Dim strSQL as string
strSQL = "Select Distinct RecType, CBEDSCourse from [" & TblNmStr &  "] WHERE RecType='C' and CrsType='" & CTypeArr(CTypeLpCnt) & "' " & PTCritArr(PTypeLpCnt))
debug.print strSQL
Set CBEDSRst = CurrentDb.OpenRecordset(strSQL)

Open in new window

0
 

Author Comment

by:needhelpfast569
ID: 38780928
Hi Capricorn1,

Both of the fields are numbers

the compiler did not like the line dropping those chracters ' and " added the editing back in and the compiler accepted the line again

what is strange is I have an access 2003 version of the program and this line works but having the problem with same line in the Access 2007 version
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38780939
what does this two function do

CTypeArr(CTypeLpCnt)  

 PTCritArr(PTypeLpCnt)


can you upload a copy of the db?
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38780947
needhelpfast -

You might have missed my comment earlier.

Is TblNmStr a string variable or the name of an actual table?

If it is an actual table name, try this:

Dim strSQL as string
strSQL = "Select Distinct RecType, CBEDSCourse from  [TblNmStr] WHERE RecType='C' and CrsType=" & CTypeArr(CTypeLpCnt) &  PTCritArr(PTypeLpCnt))
debug.print strSQL
Set CBEDSRst = CurrentDb.OpenRecordset(strSQL)

Open in new window


The debug.print strSQL line will write the query string to the debugger window.

If you copy/paste it here, it will give us a better idea of where your query is going wrong.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 38780985
<what is strange is I have an access 2003 version of the program and this line works but having the problem with same line in the Access 2007 version >

so the line works in A2003,

open your VBA window, then
Tools > References

see if you have a reference with "MISSING" prefix
uncheck and select the available version

Do a DEBUG > COMPILE

make sure that all errors raised is corrected
0
 

Author Comment

by:needhelpfast569
ID: 38781065
The references look good
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 38781069
upload a copy of the db
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38781071
Ok - I'm going to click "unmonitor" here and leave this to cap1 - very difficult to help if you don't respond to the comments posted.
0
 

Author Closing Comment

by:needhelpfast569
ID: 38787523
problem was a reference out of order
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

860 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