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
LVL 1
jvantassel1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JezWaltersCommented:
Personally, I think it makes code clearer to drop the "Me." prefix - you don't need it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.