By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Type Mismatch Error Dealing with SELECT CASE and Recordsets

P: 6
I am completely stumped on what seems to be a completely simple thing.
What I'm trying to do is use a SELECT CASE with a recordset. The SELECT CASE looks at one field from the recordset to establish the CASE's. I looked at the table that this field comes from and the field's data type is "text." When I make my CASE's, the program runs fine if I just put numbers for the requirements.

I.E. Case "734"

The problem I am having is that as soon as I enter in any type of text for the requirement of the CASE, I get a "Type Mismatch" Error.

I.E. Case "INACTIVE 734"

I've posted some of my code below:

Expand|Select|Wrap|Line Numbers
  1. Set jobnumrcdset = db.OpenRecordset("SELECT JobNumbers.[Job Number], JobNumbers.[Machine #] " + _
  2.                                 "FROM JobNumbers ORDER BY JobNumbers.[Job Number];", dbOpenDynaset)
  3.  
  4. Select Case jobnumrcdset![Machine #]
  5.         Case "734" Or "735" Or "901" Or "894" Or "1094" Or "981" Or "INACTIVE 734" 
  6.               jobnumrcdset.Edit
  7.               jobnumrcdset![Machine #] = sInactive & jobnumrcdset![Machine #]
  8.               jobnumrcdset.Update
  9.         Case Else
  10. End Select

Could someone tell me why I'm getting this error?
Thanks!
Sep 9 '10 #1

✓ answered by TheSmileyCoder

Your using the syntax for the Select Case wrong. You need to write:
Expand|Select|Wrap|Line Numbers
  1. Case "734","735","901","894","1094","981","INACTIVE 734" 
in order to achieve your result.

Share this Question
Share on Google+
3 Replies


TheSmileyCoder
Expert Mod 100+
P: 2,321
Your using the syntax for the Select Case wrong. You need to write:
Expand|Select|Wrap|Line Numbers
  1. Case "734","735","901","894","1094","981","INACTIVE 734" 
in order to achieve your result.
Sep 9 '10 #2

P: 6
I knew it was something easy! It works perfect now, thanks SmileyOne!
Sep 9 '10 #3

NeoPa
Expert Mod 15k+
P: 31,308
Nice one Smiley. I missed that.

Jake, please set Smiley's post as Best Answer if you have a spare minute.
Sep 10 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.