Toggle Sysntax For Expression - And Not IsNull

G

Guest

Can someone give me a little syntax. I have a checkbox called Active that by default = True. I also have a control on the same form that is called InactiveDate. I have it working so that if a date is entered in the InactiveDate field, the Active checkbox automatically reverts to False. Cool. But the user can still go back and check the box as True, even if there is a date in the Inactive field. What I need is a way so that is if the user ploaces his cursor in the InactiveDate date field and removes the date, the Active check box will automatically revert back to true. Kind of toggle sort of thing. Here is part of the correct code, both are on AfterUpdate: Th

Active_AfterUpdate "Don't think this is working
If Me.InactiveDate And Not IsNull(Me.[InactiveDate]) The
Me.Active = Fals
ElseIf Me.InactiveDate And IsNull(Me.[InactiveDate]) The
Me.Active = Tru

InactiveDate_AfterUpdate ' This Works
If Me.InactiveDate And Not IsNull(Me.[InactiveDate]) The
Me.Active = False
 
G

Graham R Seach

Private Sub InactiveDate_AfterUpdate()
Me.Active = Not (IsDate(Me.InactiveDate))
Me.Active.Locked = Not (Me.Active)
End Sub

Private Sub Active_AfterUpdate()
If Not Me.Active Then
Me.InactiveDate = Date()
Me.InactiveDate.SetFocus
Me.Active.Locked = True
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html


MBoozer said:
Can someone give me a little syntax. I have a checkbox called Active that
by default = True. I also have a control on the same form that is called
InactiveDate. I have it working so that if a date is entered in the
InactiveDate field, the Active checkbox automatically reverts to False.
Cool. But the user can still go back and check the box as True, even if
there is a date in the Inactive field. What I need is a way so that is if
the user ploaces his cursor in the InactiveDate date field and removes the
date, the Active check box will automatically revert back to true. Kind of
toggle sort of thing. Here is part of the correct code, both are on
AfterUpdate: Thx
Active_AfterUpdate "Don't think this is working'
If Me.InactiveDate And Not IsNull(Me.[InactiveDate]) Then
Me.Active = False
ElseIf Me.InactiveDate And IsNull(Me.[InactiveDate]) Then
Me.Active = True


InactiveDate_AfterUpdate ' This Works'
If Me.InactiveDate And Not IsNull(Me.[InactiveDate]) Then
Me.Active = False
 
G

Guest

Thanks a million Graham! It works great. Now I just need to sit down, study it and understand it. Its really great to have someone like yourself help out a newbie like me. Thanks again from Wisconsin.
 

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