[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Run-time error 13 type mismatch

Posted on 2013-01-15
10
Medium Priority
?
629 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
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!

 
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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

872 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