Else If Directive

C

Curtis Stevens

What's wrong with my code? When I click on Status:

If Null, change value to Open
If it says Open, change to Closed
If it says Closed, change to Open

Private Sub Status_Click()
If Me.Status = Null Then Me.Status = "Open"
ElseIf Me.Status = "Open" Then Me.Status = "Closed"
ElseIf Me.Status = "Closed" Then Me.Status = "Open"
End Sub

Thanks
Curtis
 
M

mscertified

You can't test for Null like that, try IF ISNULL(Me.Status) Then ...

Dorian
 
K

Klatuu

There are two problems.
You can only test for a Null value using the IsNull function.
You are missing an End If.

A suggestion:

If IsNull(Me.Status) Or Me.Status = "Closed" Then
Me.Status = "Open"
Else
Me.Status = "Closed"
End If
 
C

Curtis Stevens

Man, you guys make this seem so easy!!!!! Don't know what I would do without
this forum.

Awesome!

Curtis
 
D

David F Cox

if "open", "closed" and null are the only options:


If Me.Status = "Open" Then
Me.Status = "Closed"
Else
Me.Status = "Open"
Endif
 
C

Curtis Stevens

Ah, that's one way to look at it too! A more cleaner way.... Programming,
you really have to think about this stuff logically!

Thank ya!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top