Results 1 to 4 of 4
  1. #1
    vickan240sx is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    34

    update field once upon opening, but not the 2nd time the record is opened

    Hi,



    I currently have a form that has a date/time field that is automatically updated when the form is loaded.

    However, when this form is closed and reopened again, the field re-updates. How can I prevent this field from re-updating. Is there some sort of VBA code that I can enter that does this when the form is loaded? Like, (if field null, then update)?

    Thank you for your help!

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    Try this in the Open Event:

    If IsNull(Me.[YourTxtBoxName]) then
    Me.[YourTxtBoxName] = Date()
    End If
    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
    vickan240sx is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    34
    Quote Originally Posted by Bob Fitz View Post
    Try this in the Open Event:

    If IsNull(Me.[YourTxtBoxName]) then
    Me.[YourTxtBoxName] = Date()
    End If
    Hi,

    What would be the difference of Me! vs Me.? The original code that I had in place had an "!".

    Code:
     
    Me!LDDDistributor = Now()
    Thank you

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,540
    I think that Now() returns the date and time. Date() just returns the date.

    (!) or (.) I don't think it matters which you use here. I usually use (.) but take a look at: http://datagnostics.com/dtips/bangdot.html
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 9
    Last Post: 05-12-2012, 12:16 PM
  2. Replies: 4
    Last Post: 07-27-2011, 09:25 AM
  3. Replies: 1
    Last Post: 07-27-2011, 09:19 AM
  4. NEW sql update HELP :( (time field problem)
    By ducthang88 in forum Programming
    Replies: 1
    Last Post: 12-05-2010, 12:03 AM
  5. Replies: 4
    Last Post: 07-22-2009, 02:33 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