Solved

Run-time error 13 type mismatch

Posted on 2013-01-15
10
595 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 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 119

Expert Comment

by:Rey Obrero
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 119

Accepted Solution

by:
Rey Obrero 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now