List Box (1 Viewer)

dadrew

Registered User.
Local time
Today, 17:36
Joined
Sep 15, 2003
Messages
186
Can someone please tell me why this piece of code dosent work. Im sure im missing something really obvious! The problem is that it only works one way. i.e. on the top part of thr code.

Private Sub Unit_Name_AfterUpdate()
If Me.Unit_Name = "114" Or "115" Or "213" Or "214" Or "215" Or "564" Or "565" Or " 714" Or "715" Then
Me.Check392 = False
Me.Check392.Enabled = False
Me.Check736.Enabled = True
End If
If Me.Unit_Name = "111" Or "112" Or "211" Or "212" Or "331" Or "332" Or "334" Or " 335" Or "336" Or "337" Or "338" Or "339" Or "561" Or "562" Or "563" Or "711" Or "712" Or "713" Then
Me.Check392.Enabled = True
Me.Check736 = False
Me.Check736.Enabled = False
End If

End Sub
 
R

Rich

Guest
Look up the In operator, and are these Numeric values, if so they shouldn't be surrounded by quotes
 

dadrew

Registered User.
Local time
Today, 17:36
Joined
Sep 15, 2003
Messages
186
Sorry, I dont understand, the numbers are from a value list and they are a text field
 

pottera

Registered User.
Local time
Tomorrow, 02:36
Joined
Sep 3, 2002
Messages
236
I'm not sure on this but I think each of the OR statements needs to be syntactically complete (eg if name = "114" or name = "115" etc).

Why not use the Case statement instead
Code:
Select Case name
   Case "114","115",...
     ... block of statements
   Case "117", "118",...
     ... block of statements
End Select
 

Users who are viewing this thread

Top Bottom