
Originally Posted by
bkirsch
This is what I entered into the on click code but it is returning an error...It says Invalid use of Null...?
Private Sub Received_Click()
If Received.Value = True Then
RECEPTION_DATE.SetFocus
RECEPTION_DATE.Text = "Now()"
Else
RECEPTION_DATE.SetFocus
RECEPTION_DATE.Text = "Null"
End If
End Sub
You don't need to set the focus to the field.
You don't need ".VALUE". It is the default property.
The ".Text" property holds the uncommitted value. Not appropriate in this case.
You are trying to put the text string "Now()" into a date type field. (raises an error)
If [Received] is a boolean (Yes/No) type field in the table and [RECEPTION_DATE] is a date type field, try this code in the after update event of the [Received] check box:
Code:
Private Sub Received_AfterUpdate()
If Me.Received = True Then
'if you want only the date, use
Me.RECEPTION_DATE = Date
'if you want date and time, use
' Me.RECEPTION_DATE = Now()
Else
Me.RECEPTION_DATE = Null
End If
End Sub