Results 1 to 8 of 8
  1. #1
    Bebobrokstedy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    5

    How to add timestamp when saving form

    Hi there,

    I'm relatively new to Access and have built a few basic forms each with a button that both saves the data in the form and then closes the form.

    I have a time stamp on the form for when someone opens it but also want to add a time stamp to note down the time when someone saves an entry. I have been trying to do this by adding the code on the save button command but with no luck.

    The code I currently have is:

    Private Sub Command16_Click()
    Value = Now()
    DoCmd.GoToRecord , , acNewRec
    DoCmd.Close
    MsgBox "Thank you - Your entry has been saved"
    End Sub

    Through loads of testing and errors I cant work out how to record the time that the form data was saved

    Can anyone help please!?

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    IMHO the best place for this kind of thing would be in the forms BeforeUpdate event. If a record is added/edited it always fires.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    Bebobrokstedy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    5
    Thanks Bob.

    I'm pretty new to Access so should have said. The form is setup purely to collect data so those entering it will always be entering a blank form. They're unable to navigate through any other previous entries.

    Is there a way to code the time stamp so that when they save it records the time that the form was saved. This way I can manage how long these cases are taking to process!?

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Add a field to the table that the form is bound to. With the table in design view set the new field's Default value to Now().
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    Bebobrokstedy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    5
    Thanks for confirming Bob.

    I have a field that records the time that the form was opened using default value Now().

    I'm now trying to record the time that the form is saved to manage how long it takes between the form being opened and all the data input and the form being saved.

    Any ideas?

  6. #6
    Bebobrokstedy is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2020
    Posts
    5
    Thanks Bob!

    I used the BeforeUpdate event and added a field to the bound table to record time saved and then added:

    Me! [Time Saved] .Value=Now()

    And it worked!

    Thanks very much for the help
    Last edited by Bebobrokstedy; 08-24-2020 at 08:38 AM. Reason: Spelling and repeat words

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    Quote Originally Posted by Bebobrokstedy View Post
    Thanks Bob!

    I used the BeforeUpdate event and added a field to the bound table to record time saved and then added:

    Me! [Time Saved] .Value=Now()

    And it worked!

    Thanks very much for the help
    If you follow the instruction that I gave in post #4 then NO code would be needed
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    I have a time stamp on the form for when someone opens it but also want to add a time stamp to note down the time when someone saves an entry.
    can you clarify exactly what you require

    A user opens a form set to dataentry =true but don't enter anything
    they go for a coffee
    they come back 10 minutes later and complete a few of the fields
    they take a telephone call
    they get back to the form and complete it
    then they do what? close the form? or save the record and go to a new record?

    what two times are you trying to get? when they open the form? when they close the form? when they start entering data in a new record? when they save the record? something else?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Timestamp on Buttonclick
    By didiomm in forum Programming
    Replies: 4
    Last Post: 09-08-2016, 01:02 PM
  2. Replies: 3
    Last Post: 04-22-2015, 04:35 AM
  3. TimeStamp Issues
    By mike760534211 in forum Access
    Replies: 3
    Last Post: 01-08-2014, 04:51 PM
  4. Insert A TimeStamp
    By dandoescode in forum Forms
    Replies: 3
    Last Post: 06-25-2012, 12:34 PM
  5. Access Timestamp...
    By HMel in forum Access
    Replies: 4
    Last Post: 08-19-2008, 01:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums