Select Case syntax

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to learn the syntax for Select Case instead of using the Access
IIf function. I'm having some trouble. What I want to do is create a
function that looks at the text field called GBOBJ and if GBOBJ begins with 1
assign the name "Assets", if GBOBJ begins with 2, assign the name
"Liabilities", and so on for 9 different cases.

Any help with this would be appreciated!
 
Select Case Left(Me!GBOBJ, 1)
Case "1"
Something = "Assets"
Case "2"
Something = "Liabilities"
etc.
End Select
 
Dim GBOBJ As String
GBOBJ = "633335"
Select Case Left(GBOBJ, 1)
Case 1
MsgBox "begins with 1"
Case 2
MsgBox "begins with 2"
Case 3
MsgBox "begins with 3"
Case Else
MsgBox "begins with " & Left(GBOBJ, 1)
End Select


--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| I'm trying to learn the syntax for Select Case instead of using the Access
| IIf function. I'm having some trouble. What I want to do is create a
| function that looks at the text field called GBOBJ and if GBOBJ begins
with 1
| assign the name "Assets", if GBOBJ begins with 2, assign the name
| "Liabilities", and so on for 9 different cases.
|
| Any help with this would be appreciated!
 
Back
Top