Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Time refresh (2003 (SP2))

    Scenario, users enter information about goods, going into an oven. The date & time is a single field (text box), with the control source being '=Now()'.

    There is potential for a user to have open the data entry form, but not actually type in a record. This would mean the date/time recorded is from when the form was opened & not when the record was entered.

    I did try using the requery (on the after update on the last field on the form), but no joy.

    Ideas please [img]/forums/images/smilies/smile.gif[/img]

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Time refresh (2003 (SP2))

    I wouldn't use a control source =Now(). Instead, leave the record source blank, and use an event procedure to fill the field. Which event depends on what exactly you want to record.

    - If you want the time the user starts entering data in a new record: user the Before Insert event of the form.
    - If you want the time a new record is actually added to the table: use the After Insert event of the form.
    - If you want the time the record has last been modified (whether it is new or existing), use the Before Update event of the form.

    Example:

    Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.txtTime = Now
    End Sub

    where txtTime is the name of the text box.

  3. #3
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Time refresh (2003 (SP2))

    As easy as that. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

    Cheers

  4. #4
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Time refresh (2003 (SP2))

    OK I guess I'm doing something wrong.

    I wanted the date/time recorded like in your 2nd example, but it's not happening; the field gets left blank.

    I'm attaching a sample (a bit of a messy one though, sorry). The relevant form is 'FrmDataEntry'

    NB due to some WIP changes, there aren't any Primary fields currently set (but will be the date/time & furnace)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Time refresh (2003 (SP2))

    Your database appears to be slightly corrupt. The After Insert event never occurs. Compact and repair doesn't help, but if you create a blank new database and import all database objects from your database into it, the After Insert event should work as intended.

  6. #6
    4 Star Lounger
    Join Date
    May 2001
    Location
    Oxfordshire
    Posts
    456
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Time refresh (2003 (SP2))

    Yep, that''s done it.

    Cheers <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

Posting Permissions

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