Type Mismatch Error Dealing with SELECT CASE and Recordsets

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JaketheSnake27
    New Member
    • Sep 2010
    • 6

    #1

    Type Mismatch Error Dealing with SELECT CASE and Recordsets

    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:

    Code:
    Set jobnumrcdset = db.OpenRecordset("SELECT JobNumbers.[Job Number], JobNumbers.[Machine #] " + _
                                    "FROM JobNumbers ORDER BY JobNumbers.[Job Number];", dbOpenDynaset)
    
    Select Case jobnumrcdset![Machine #]
            Case "734" Or "735" Or "901" Or "894" Or "1094" Or "981" Or "INACTIVE 734" 
                  jobnumrcdset.Edit
                  jobnumrcdset![Machine #] = sInactive & jobnumrcdset![Machine #]
                  jobnumrcdset.Update
            Case Else
    End Select

    Could someone tell me why I'm getting this error?
    Thanks!
  • TheSmileyCoder
    Recognized Expert Moderator Top Contributor
    • Dec 2009
    • 2322

    #2
    Your using the syntax for the Select Case wrong. You need to write:
    Code:
    Case "734","735","901","894","1094","981","INACTIVE 734"
    in order to achieve your result.

    Comment

    • JaketheSnake27
      New Member
      • Sep 2010
      • 6

      #3
      I knew it was something easy! It works perfect now, thanks SmileyOne!

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32669

        #4
        Nice one Smiley. I missed that.

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

        Comment

        Working...