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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA for Date() on form?

Status
Not open for further replies.

TomYC

Technical User
Dec 11, 2008
191
US
OK, I give up--
I've been working on a checkbox and a date text box.
If the checkbox is cleared/blank, then the date box is also, or cleared if it's not blank; if it's checked, then the datebox should put in today's date. The former is happening, but not the latter, and I don't know why?
Here is the AfterUpdate code on the checkbox:
Private Sub ckResolved_AfterUpdate()
If Me.ckResolved = 0 Then
Me!txtResolvedDAte.Value = Null
Else
If Me!txtResolvedDAte.Value = Null Then
Me!txtResolvedDAte.Value = Now()
End If
End If
End Sub
 
Replace this:
If Me!txtResolvedDAte.Value = Null Then
with this:
If IsNull(Me!txtResolvedDAte.Value) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You can't use "=" to compare anything with Null. Null is like "unknown". You can't compare txtResolvedDate with unknown. You can check for IsNull(Me.txtResolvedDate).

Code:
Private Sub ckResolved_AfterUpdate()
  If Me.ckResolved = 0 Then
    Me!txtResolvedDAte = Null
   Else
    If IsNull(Me!txtResolvedDAte) Then
      Me!txtResolvedDAte = Now()
    End If
  End If
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top