if ... then... else is not working correctly

  • Thread starter Thread starter Silvio
  • Start date Start date
S

Silvio

For some reason the "If Toolbar = 4 Or 10 Or 11 Or 12 Or 13 Then" line does
not work. If I enter only one number (e.g. If Toolbar = 12 then) then it
works fine. What I am doing wrong?


Dim Toolbar As Integer
Toolbar = DLookup("ToolbarID", "qryCurrentUser")
If Toolbar = 4 Or 10 Or 11 Or 12 Or 13 Then
Me.AddCycle.Enabled = False
Me.TxHold.Enabled = False
Me.frmHoldsSub.Enabled = False
Else
Me.AddCycle.Enabled = True
Me.TxHold.Enabled = True
Me.frmHoldsSub.Enabled = True
End If
 
For some reason the "If Toolbar = 4 Or 10 Or 11 Or 12 Or 13 Then" line does
not work. If I enter only one number (e.g. If Toolbar = 12 then) then it
works fine. What I am doing wrong?

Dim Toolbar As Integer
Toolbar = DLookup("ToolbarID", "qryCurrentUser")
If Toolbar = 4 Or 10 Or 11 Or 12 Or 13 Then
    Me.AddCycle.Enabled = False
    Me.TxHold.Enabled = False
    Me.frmHoldsSub.Enabled = False
Else
    Me.AddCycle.Enabled = True
    Me.TxHold.Enabled = True
    Me.frmHoldsSub.Enabled = True
End If

one way around it (because I'm being lazy, I guess) is to use a
different version of IF stuff..

Select Case Toolbar
Case 4,10,11,12,13
Me.AddCycle.Enabled = False
Me.TxHold.Enabled = False
Me.frmHoldsSub.Enabled = False
Case Else
Me.AddCycle.Enabled = True
Me.TxHold.Enabled = True
Me.frmHoldsSub.Enabled = True
End Select
 
Back
Top