Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then statement not working....how simple can it be?

Status
Not open for further replies.

ag90fox

IS-IT--Management
Mar 14, 2002
17
0
0
US
O.k, I'm sorry to ask such a blatant question as this, but the following code will not execute in my access database (2003), and it seems so pitifully simple, yet will not work. Could someone kindly straighten me out. Thanks!

Private Sub DateCompleted_AfterUpdate()
If Me Is Null Then Completed = 0
End If
Completed = -1
End Sub


Scenario: after a user updates the DateCompleted field, I want the Completed check box to be updated. If the DateCompleted field was changed to a blank field due to a correction, the checkbox should be cleared. If an existing date is changed or one is added for the first time, checkbox should be checked.
 
'me' refers to the form so you'll need

If IsNull (Me.DateCompleted.Value) then
Me.Completed.Value = 0
else
Me.Completed.Value = -1
end if

 
sozzer is 100% correct, on both accounts.
I just wanted to "show off", and show a nice simple way of
expressing the same criteria.

Since the chkCompleted is soley dependant upon,
whether DateCompleted is null or not,


Private Sub DateCompleted_AfterUpdate()
Me.Completed = Not IsNull(DateCompleted)
End Sub



 
Just to beat the dead horse to death...

Why have the checkbox? If you want to know if the thing is complete, simply check if there is a value in the completed date rather than test a check box... Just a thought, but it seems like having the checkbox and the date field questions the normalization of the database.

The horse is dead.

"If you say you can, or you say you can't, you're right!"
-- Henry Ford
 
I agree, it would indeed be better if you checked data to see if it is empty or not, unless you use that checkbox to lock the unused parameters....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top