Select Case

  • Thread starter Thread starter Joan
  • Start date Start date
J

Joan

Can anyone help with the following? I am trying to set the
string aAbsent according to the contents of the field
rcdabsent!eventname with a select case but I cannot figure
out how to achieve this.

Any help welcome

Joan

Dim aAbsent As String
Select Case rcdabsent!eventname
Case rcdabsent!eventname = "holiday"
aAbsent = "holidays"
Case rcdabsent!eventname = "ABSENCE"
aAbsent = "absence"
Case rcdabsent!eventname = "sick"
aAbsent = "sdays"
End Select
Debug.Print aAbsent
 
Don't repeat the chosen variable (or field, in this case).

Dim aAbsent As String
Select Case rcdabsent!eventname
Case "holiday"
aAbsent = "holidays"
Case "ABSENCE"
aAbsent = "absence"
Case "sick"
aAbsent = "sdays"
End Select
Debug.Print aAbsent

To compare for equality, nothing follows the Case keyword except the value
you are comparing with.

For inequality, use:
Case is > [value]

The VBA editor will help out, as long as you don't repeat the field as you
did in your example.

HTH

Paul
 
Thanks Paul
Works a treat.
-----Original Message-----
Don't repeat the chosen variable (or field, in this case).

Dim aAbsent As String
Select Case rcdabsent!eventname
Case "holiday"
aAbsent = "holidays"
Case "ABSENCE"
aAbsent = "absence"
Case "sick"
aAbsent = "sdays"
End Select
Debug.Print aAbsent

To compare for equality, nothing follows the Case keyword except the value
you are comparing with.

For inequality, use:
Case is > [value]

The VBA editor will help out, as long as you don't repeat the field as you
did in your example.

HTH

Paul

Can anyone help with the following? I am trying to set the
string aAbsent according to the contents of the field
rcdabsent!eventname with a select case but I cannot figure
out how to achieve this.

Any help welcome

Joan

Dim aAbsent As String
Select Case rcdabsent!eventname
Case rcdabsent!eventname = "holiday"
aAbsent = "holidays"
Case rcdabsent!eventname = "ABSENCE"
aAbsent = "absence"
Case rcdabsent!eventname = "sick"
aAbsent = "sdays"
End Select
Debug.Print aAbsent


.
 
Back
Top