If...Then....Else

L

Liliane

My form has a combo box (Audit_Category) and several check boxes refer to
each category. When I choose something in the combo box, I need the related
check box to be checked. I wrote a piece of codes for this function. Now I
can add and delete records, but when I change the Audit_Category from one
category to another, the related check box for the new category can't be
checked. I paste my codes here. I run the codes step by step, it seems
there is something wrong in the first IF branch. I guess the IF condition is
incorrect. Please help me. Thanks a million.

Private Sub Audit_Category_AfterUpdate()

If Audit_Category <> Null And Commercial = True Then
'this is not the first time data entry, the records are changed
here'
Me.Controls(Audit_Category.OldValue) = False
Me.Controls(Audit_Category) = True
Else
'the drop down list is null, check if it's first time data entry
or deleting
If Commercial = True Or Commissioning = True Or Communication =
True Or Construction = True _
Or Design = True Or Env_CoA = True Or Environment = True Or
General = True _
Or OHS = True Or Procurement = True Or Project_Fin = True Or
Rail_Safety = True _
Or Risk = True Or TIDC_Fin = True Then
'drop down list is null and check box is not
null--Delete-->set all check boxes as false'
Commercial = False
Commissioning = False
Communication = False
Construction = False
Design = False
Env_CoA = False
Environment = False
General = False
OHS = False
Procurement = False
Project_Fin = False
Rail_Safety = False
Risk = False
TIDC_Fin = False
Else
'first time data entry, set related checkbox as true'
Me.Controls(Audit_Category) = True
End If
End If

End Sub
 
T

Tom van Stiphout

On Tue, 19 Aug 2008 21:14:00 -0700, Liliane

All tests with Null are Null.
Rewrite this as:
If Not IsNull(Audit_Category) And ...

-Tom.
Microsoft Access MVP
 

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