Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2015
    Posts
    51

    Question Unanswered: current system time

    I have a continuous form with a control linked to a table field. The control name is "Ctime".
    I have set the default value of the control to =time()

    When I open the form the control shows the current time. but once I begin to add information to the record and the next record available appears below it, it also shows the current time. and If i go to that next record it does not update to the current time when im editing.....


    How do i get the current time to function on a continuous form

  2. #2
    Join Date
    Jul 2015
    Posts
    51
    basicly how do I get the time stamp to update when I go to a new record on the continuous form, instead of using the time when i opened the form.

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Is the control bound to a data source (column) in the underlying table?
    What you could do is explicitly set the tine in the controls before update event.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Apr 2004
    Location
    Derbyshire, UK
    Posts
    789
    Provided Answers: 1
    Hi

    The time will only be correct at the time the record is started ie. when the Default value is set I believe.

    What I would suggest is set the time in the BeforeUpdate event, BUT only if it is a new record.
    Code:
    If Me.NewRecord Then Ctime = Time()
    HTH


    MTB

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Timestamps are usually done in the Form_BeforeUpdate event, as has been suggested, but FYI, anytime you need something to occur when moving to another Record, such as setting a Field to the current time, the assignment needs to be in the Form_Current event. If you only want it to happen on a New Record, follow MikeTheBike's advice.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Jul 2015
    Posts
    51
    SO, if I use mikes suggestion, if the user needs to change the time for any reason it does not allow you to do that.
    I think I may go another way with this, I do not want to show the *(new) record at the bottom of the continuous form, and set my allow additions to no, and I'm going to have an add record button. with the on click command:


    Dispatch_log_form.AllowAdditions = True
    DoCmd.GoToRecord , , acNewRec
    Dispatch_log_form.Date = Date And Dispatch_log_form.Time = Time()
    'Refresh
    Dispatch_log_form.AllowAdditions = False
    Dispatch_log_form.EventType.SetFocus

    BUT when I click on the add record button I get an error: Object required (Error 424)


    Any ideas here guys?

  7. #7
    Join Date
    Jul 2015
    Posts
    51
    OKay nevermind on that one.... I figured that out..... but NOW it shows the time as 0:00 and not the current time..... This form is a pain in the butt.... I think it sets the time but once the allow additions is set to false it resets to 0:00

  8. #8
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    [code]Dispatch_log_form.Date = Date And Dispatch_log_form.Time = Time()[code]
    ..what is this supposed to do...?

    [code]Dispatch_log_form.Date = Date
    Dispatch_log_form.Time = Time()[code]
    ...I could believe (sort of)
    [code]Dispatch_log_form.Date = Date()
    Dispatch_log_form.Time = Time()[code]

    ...please tell me you aren't storing the date and time separtely for the same row.
    use a single datetime column. the c ue is in the datatype name (datetime), whicnh stores a date AND a time as the same time. storing them separately menas having two datetime column, or worse still two coloums of other datatypes (and please, I hope that is NOT what you are doing, and especailly NOT as type string)
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •