Add Now() when a checkbox is clicked

G

Guest

Is it possible to have Now() enter into a field when a yes/no checkbox is
clicked? I have a form with field name InProgress that is a yes/no checkbox.
I have another field named InProgressDate that I would like Now() to show up
when I check the InProgress checkbox. Is this possible?
 
C

Carl Rapson

Ryan said:
Is it possible to have Now() enter into a field when a yes/no checkbox is
clicked? I have a form with field name InProgress that is a yes/no
checkbox.
I have another field named InProgressDate that I would like Now() to show
up
when I check the InProgress checkbox. Is this possible?

Yes, create an event handler for the checkbox's Click event (or the
AfterUpdate event, it really doesn't matter which). In that event, add the
code:

InProgressDate = Now

Carl Rapson
 
A

Al Campagna

Ryan,
I assume you want no InProgressDate if InProgress is False
Use the AfterUpdate event of InProgress to update the InProgressDate

Private Sub InProgress_AfterUpdate()
If InProgress = True Then
InProgressDate = Now()
Else
InProgressDate = Null
End If
End Sub
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
G

Guest

You know your code Al, thanks for your help.

Al Campagna said:
Ryan,
I assume you want no InProgressDate if InProgress is False
Use the AfterUpdate event of InProgress to update the InProgressDate

Private Sub InProgress_AfterUpdate()
If InProgress = True Then
InProgressDate = Now()
Else
InProgressDate = Null
End If
End Sub
--
hth
Al Campagna . Candia Computer Consulting . Candia, NH USA
Microsoft Access MVP
http://home.comcast.net/~cccsolutions

"Find a job that you love, and you'll never work a day in your life."
 
J

John W. Vinson

Is it possible to have Now() enter into a field when a yes/no checkbox is
clicked? I have a form with field name InProgress that is a yes/no checkbox.
I have another field named InProgressDate that I would like Now() to show up
when I check the InProgress checkbox. Is this possible?

Sure. Open the form in design view; view its Properties; and view the
properties of the checkbox. On the Events tab select the AfterUpdate event.
Click the ... icon and choose Code Builder. Access will put you into the VBA
editor with a Sub and End Sub line; edit it to

Private Sub yourcheckboxname_AfterUpdate()
If Me.yourcheckboxname Then ' set the date if the checkbox has
' been set to True
Me.InProgressDate = Now
End If
End Sub

John W. Vinson [MVP]
 

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