Results 1 to 7 of 7
  1. #1
    Smiffy3594 is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2020
    Posts
    3

    Question generate current date and time after field entry

    Am trying to automatically generate the date and time in a field after another field is filled in, so basically when field 17 is filled in I want the date and time that entry was input in field 18 (e.g : 19-Feb-2020, 12:58:42)



    Have tried using the after insert option but cannot work out the formula.

    Can anyone help

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    (no programming)
    what about setting DEFAULT VALUE = now()

    or (programming)
    in field17_afterupdate event:
    field18 = now()

  3. #3
    Smiffy3594 is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2020
    Posts
    3
    When you say no programming / programming can you be more specific have not used access for many many years and not 100% where these go

    No programming - direct into field
    Programming - input in after event formula ?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    in the text box property: DEFAULT VALUE
    set it to =NOW()

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    in the text box property: DEFAULT VALUE
    set it to =NOW()

    But if you want the date to fill in ONLY when box 17 is filled, then you must use programming:
    in the event property AFTERUPDATE , for txtBox17,
    click the drop box for AFTERUPDATE property
    select [event procedure]
    click the Elipsis button at the end of the property to get into VBE
    enter the fill date code:

    Code:
    Private Sub txtBox17_AfterUpdate()
      txtBox18 = now()
    
    End Sub

  6. #6
    Smiffy3594 is offline Novice
    Windows 10 Access 2007
    Join Date
    Feb 2020
    Posts
    3
    sorry Ranman256 you've lost me on event property and afterupdate.

    I have managed to get DATE/TIME by using before change option but if I remove data in the line (I cannot remove the date and time) and if I change anything else in the same line, it give me the date and time which I cant remove.
    Click image for larger version. 

Name:	Capture.PNG 
Views:	13 
Size:	1.6 KB 
ID:	40974

  7. #7
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,557
    Hi Smiffy

    If you switch to Design View of your Form and then select the Control 17 ( When you create a Form based on a table, the fields from the table are referred to as Controls on the Form)

    When you have the Control selected - RightClick and select Properties from the Listed Options.

    Then select the Event Tab

    Click in the Row that says "After Update" and at the end of this row you will see 3 Dots (...) - Click on the 3 Dots to display a Choose Builder Window. Select Code Builder and then Click OK.

    This will display the "Microsoft Visual Basic for Applications" Window with the Cursor in the Blank 2nd Row below Private SubControl17Name_AfterUpdate().

    In the Blank row you would type the following:-

    Me.Control18Name = Now()

    The final After Update will look like below:-

    Private Sub Control17Name_AfterUpdate()
    Me.Control18Name = Now()
    End Sub


    Remember to replace Control17 & Control 18 with the actual names of your fields.

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

Similar Threads

  1. Replies: 8
    Last Post: 07-18-2019, 01:36 AM
  2. Replies: 5
    Last Post: 07-06-2018, 01:30 PM
  3. Replies: 2
    Last Post: 01-16-2015, 04:22 PM
  4. Enter current date and time into subform field
    By tonybrecko in forum Forms
    Replies: 8
    Last Post: 06-16-2013, 09:58 PM
  5. Date/Time entry field on a form
    By Ted C in forum Forms
    Replies: 1
    Last Post: 06-22-2010, 12:28 PM

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