Show time when checkbox checked

M

Michael

Hello,

I'm creating a database that allows work orders to be
entered and tracked. I have two date/time fields in the
data table. The first of these, records the present time
on the computer when a user starts entering a work order
request. The second field should show the date/time the
work order is completed, which will be indicated by
clicking a checkbox. Is there a way I can set this second
checkbox so that it shows the date/time on the computer
when the checkbox for that record is checked?

Thanks in advance,

Michael
 
W

Wayne Morgan

In the AfterUpdate event of the checkbox, set the value of the textbox bound
to the date/time field that you are storing this value in.

Example:
If Me.chkMyCheckbox = True Then Me.txtMyTextbox = Now

You will also need to decide how you want to handle someone unchecking and
rechecking the checkbox.
 
M

Michael

Hello Wayne,

I tried your suggestion, but I keep getting compiling
errors. Here's what I wrote:

Private Sub Form_AfterUpdate()
If MASSILLON_WORK_ORDERS_FORM.COMPLETE = True Then
MASSILLON_WORK_ORDERS_FORM.COMPLETED_DATE_AND_TIME = Now
End Sub

The first half of that (up through the "Then") is shown in
yellow. The two field forms in question get their data
from a query that pulls all records from the data table
for the database. I tried adding and "Else" statment
after that, but it didn't work. I'm definitely no expert
on Visual Basic, so I don't know where I'm going wrong
here.

Thanks again for your help.

Michael Bentfeld,
Rayco Mfg.
 
G

Guest

Hello again,

I tried the suggestion posted by Wayne, which resulted in
the following code:

Option Compare Database

Private Sub Form_AfterUpdate()
If MASSILLON_WORK_ORDERS_FORM.COMPLETE = True Then
MASSILLON_WORK_ORDERS_FORM.COMPLETED_DATE_AND_TIME = Now
End Sub

When I try running the code, I get a runtime 424 error:
object requried. The code between the "If" and the "Then"
is highlighted in yellow. The name of the form is
MASSILLON_WORK_ORDERS_FORM, the checkbox name is COMPLETE,
and the associated date/time text box is named
COMPLETED_DATE_AND_TIME. Am I doing something wrong with
the code. I don't do a lot of code writing, so my skill
level is kind of limited. I'd appreciate any
suggestions. Thanks.

Thanks again in advance,

Michael Bentfeld
Rayco Mfg.
 
W

Wayne Morgan

Michael,

By chance is the form a subform? Also, do the control and the field it is
bound to have the same name?
 
Top