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

check box after update command enters todays date in another field

Status
Not open for further replies.

hlkelly

Technical User
Jul 11, 2003
108
US
i have a check box that when checked i want it to automatically put today's date in the [date] field. i'm using the following code in the afterupdate of the check box but nothing happens. do i need to requery the date field?

Private Sub Complete_AfterUpdate()
Me![Date] = Date
End Sub

 
Hi hlpoindexter!

Try this:
On the OnClick Event of your checkbox:
Code:
Private Sub YOURCHECKBOX_Click()
If Not IsNull(Me.YOURCHECKBOX) Then
Me.date = date() 
End If
End Sub
 
OR.....

Add an unbound text box to your form with the default value set to date()
Make this field Visible = No.

Add the following code to your checkbox:
Code:
Private Sub YOURCHECKBOXNAME_Click()
If Me.YOURCHECKBOXNAME = 0 Then
Me.DATE = Null
Else
Me.DATE = Me.Text4 'text4 should = your new unbound text box
End If
End Sub
 
Looking at the sub you posted it is named complete therefore I assume the name of the control is complete? So your code should be.

If me("Complete")= True Then
Me("MyDate") = Date()
End if

You can't use Date as a field Name, bad practice.

Life's a journey enjoy the ride...

jazzz
 
Let me also mention you could add an Else in there so if it is unchecked False then

Else
Me("MyDate")=""

or NULL, Empty you get the idea I can't see your tables or code.

Life's a journey enjoy the ride...

jazzz
 
How are ya hlpoindexter . . . . .

First, [purple]Date[/purple] is a [purple]keyword[/purple] in VBA and should'nt be used as a [blue]field/control[/blue] name.

Try this:
Code:
[blue]Private Sub Complete_AfterUpdate()
Me![Date] = [purple][b]Int(Now())[/b][/purple]
End Sub[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top