Update a date/time control when check box control is updated

  • Follow


I have two columns in tbl.Jobs. One field is a bit data type that I named 
Jobs.OnHold and the control on the form is a check box. I also have a 
date/time field named HoldDate. I want the hold date field to automatically 
udpate with the current date everytime the check box control is udpated. What 
is the best way to accomplish this?
0
Reply Utf 2/15/2008 5:41:03 PM

Use the After Update event of the check box control:

    Me.txtHoldDate = Date

-- 
Dave Hargis, Microsoft Access MVP


"BrianP" wrote:

> I have two columns in tbl.Jobs. One field is a bit data type that I named 
> Jobs.OnHold and the control on the form is a check box. I also have a 
> date/time field named HoldDate. I want the hold date field to automatically 
> udpate with the current date everytime the check box control is udpated. What 
> is the best way to accomplish this?
0
Reply Utf 2/15/2008 6:26:00 PM


Thanks Dave, I should have remembered that one.

0
Reply Utf 2/15/2008 11:40:00 PM

I have a similar question. I have a field called "Sold" which is a check box. 
 When I check it I want the field "Date of Sale" to automatically fill in 
with todays date. I understand going to the "after update event" but I don't 
know what code to write.
Hope you can help. Thank you

"Klatuu" wrote:

> Use the After Update event of the check box control:
> 
>     Me.txtHoldDate = Date
> 
> -- 
> Dave Hargis, Microsoft Access MVP
> 
> 
> "BrianP" wrote:
> 
> > I have two columns in tbl.Jobs. One field is a bit data type that I named 
> > Jobs.OnHold and the control on the form is a check box. I also have a 
> > date/time field named HoldDate. I want the hold date field to automatically 
> > udpate with the current date everytime the check box control is udpated. What 
> > is the best way to accomplish this?
0
Reply Utf 2/16/2008 9:53:00 PM

When you say field, we need to qualify that.  Forms don't have fields, they 
have controls.  Tables and queries have fields.  So, to answer your question, 
assuming Sold and Date Of Sale are actually controls on your form, it would 
be:

Private Sub Sold_AfterUpdate()
    If Me.Sold = True Then
        Me.[Date Of Sale] = Date
    End If
End Sub

If you posted field named instead of control names, use the names of the 
controls the fields are bound to.  Note the brackets [] around Date Of Sale.  
That is necessary because you used spaces in a name.  Names should not have 
spaces or any other special characters.  They should contain only letters, 
numbers, and the underscore character.  They should also not be Access 
reserved names like Date, Time, Name, Description, Year, Month, Day, etc.

Being careful about your naming will save you a lot of headaches.
-- 
Dave Hargis, Microsoft Access MVP


"maryb" wrote:

> I have a similar question. I have a field called "Sold" which is a check box. 
>  When I check it I want the field "Date of Sale" to automatically fill in 
> with todays date. I understand going to the "after update event" but I don't 
> know what code to write.
> Hope you can help. Thank you
> 
> "Klatuu" wrote:
> 
> > Use the After Update event of the check box control:
> > 
> >     Me.txtHoldDate = Date
> > 
> > -- 
> > Dave Hargis, Microsoft Access MVP
> > 
> > 
> > "BrianP" wrote:
> > 
> > > I have two columns in tbl.Jobs. One field is a bit data type that I named 
> > > Jobs.OnHold and the control on the form is a check box. I also have a 
> > > date/time field named HoldDate. I want the hold date field to automatically 
> > > udpate with the current date everytime the check box control is udpated. What 
> > > is the best way to accomplish this?
0
Reply Utf 2/16/2008 10:01:01 PM

4 Replies
465 Views

(page loaded in 0.117 seconds)

Similiar Articles:
















7/11/2012 5:36:22 PM


Reply: