Select case

megatronixs

Registered User.
Local time
Today, 23:03
Joined
Aug 17, 2012
Messages
719
Hi all,

I need to pop up a message box if a criteria is met.
I have in a form a field "Business" that could have 2 values "Type 1" and Type 2"
There is a combo box "Material" with about 20 values, but the message box needs to pup up if "Type 1" in "business" is selected and one of the following in the combo box "Wood", "Metal" and the message box will say "You really want to change this" and then for Type 2, "Plastic", "Carton", "Stone"

I have so far the below code:
Code:
Select Case Business
   
    Case Is = "Plastic", "Carton", "Stone" And Me.Material = "Type 2"
        MsgBox ("You really want to change this!!!")
 
    Case Is = "Wood", "Metal" And Me.Material = "Type 1"
   MsgBox ("You really want to change this!!!")
        Case Else
DoCmd.CancelEvent
End Select

It should do nothing if no one of the above is selected and leave the combo box with the previous value. The message box is just to make sure the user is aware of the change.

Greetings.
 
I am assuming that your code does not do what you want it to do - customarily it is advisable to explicitly state issue or question at hand. You need to read the documentation for SELECT concerning the form and shape of criteria.
 
I don't think that is how the Case statement works. This should work though:

Code:
Select Case Business     Case "Carton"
        If Me.Material = "Type 2" Then             MsgBox ("You really want to change this!!!")         End If     Case "Stone"
        If Me.Material = "Type 2" Then             MsgBox ("You really want to change this!!!")         End If     Case "Wood"
        If Me.Material = "Type 1" Then             MsgBox ("You really want to change this!!!")
        End If
     Case Else          DoCmd.CancelEvent
 End Select
 
I did not type it that way! What funky formatting it decided to do!
 

Users who are viewing this thread

Back
Top Bottom