need help with a select case please

Jon123

Registered User.
Local time
Today, 11:18
Joined
Aug 29, 2003
Messages
668
so I'm trying to use select case on the 1st to digits of a field. I f it equals 1- then the case is meet but its not working. Will this work or no?


[CODE Case (Left(Me.Step42, 2) = "1-")][/CODE]
 
Untested, but probably

Select Case Left(Me.Step42, 2)
Case "1-"
 
Would that be a select case within a case? There are other values for that step I want to catch.

jon
 
No, the structure is

Code:
Select Case WhatToTest
  Case "1-"
    WhatToDoForThatValue
  Case "2-"
    WhatToDoFOrThatValue
  Case Else
     ...
End Select
 
I'll get out of the way.
 
Maybe I cant use select case for what I'm trying to do.

Code:
      Select Case (Me.Step42)
                Case "allok"
                    Me.Step43.Locked = True
                    Me.dat18.Locked = True
                    Me.Step42.Enabled = False
                    Me.dat18.Enabled = False
                Case Left(Me.Step42, 2) = "1-"
                     Me.Step43.Locked = True
                     Me.dat18.Locked = True
                     Me.Step42.Enabled = False
                     Me.dat18.Enabled = False
                 Case Else ' must be null
                    Me.Step43.Locked = False
                    Me.dat18.Locked = False
                    Me.Step43.Enabled = True
                    Me.dat18.Enabled = True
                 End Select
 
This doesn't look like your original post where you were interested in first 2 positions???

I'd remove the brackets
(Me.Step42)

just Me.Step42 but if it's still the first 2 positions, then Paul gave a sample.
 
My problem is I want to catch is the case is "1-abc" or "1-aaa"

to add if Step42 is "allok" or "1-aaa" or 1-abc" but not if is say "aaa"

does that make sense?
 
Last edited:
If certain value have significance, you can set up the select case to handle them, generally. What values or what patterns can Step42 have. Then, what do you want to happen for each value?
 
You can use multiple values in a single Case comparison, so . . .
Code:
Select Case SomeValue
   Case "1-aaa", "1-abc", "Alloc"
[COLOR="Green"]       'code block here[/COLOR]
   Case "1-acc", "Test some other value here"
[COLOR="Green"]       'other code block here[/COLOR]
   Case Else
[COLOR="Green"]       'catch-all code block here[/COLOR]
End Select
 

Users who are viewing this thread

Back
Top Bottom