• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

Select case

I'm trying to use a case statement in MS Access adp to produce an error if the value is any number other than 4,5,6,7,8
Here's what I was trying, but it doesn't work.

Any help is appreciated.

Select Case Me.cboDescriptionType
            Case Not 4 - 8
                Me.lblError_NotUpdateable.Visible = True
                boolError = True
        End Select
0
jvantassel1
Asked:
jvantassel1
1 Solution
 
jvantassel1Author Commented:
conducting some error checking.  I need to make sure the value isn't 4,5,6,7,8.
Here's the code that doesn't work.

Select Case Me.cboDescriptionType
            Case Not 4 - 8
                Me.lblError_NotUpdateable.Visible = True
                boolError = True
        End Select
0
 
jacob_miwCommented:
You could do it with an If-statement instead (Solution 1 below), but if you need to use the Select Case statement you can do as Solution 2 below.

Hope it helps you
Solution 1:
If Me.dboDescriptionType < 4 Or Me.dboDescriptionType>8
   Me.lblError_NotUpdateable.Visible = True
   boolError = True
End If
--------
Solution 2:
Select Case Me.cboDescriptionType
   Case 4 to 8
   Case Else
        Me.lblError_NotUpdateable.Visible = True
        boolError = True
End Select

Open in new window

0
 
JezWaltersCommented:
Personally, I think it makes code clearer to drop the "Me." prefix - you don't need it.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now