Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    1

    Unanswered: Time stamp when a field is updated

    I've searched the forum and can't find the help I need...perhaps I'm not using the right keywords.

    Anyway, I want to automatically have a time stamp entered in a field named "CancelDate" if a yes/no field named "Cancel?" is checked. On the form I use an action button for "Cancel?".

    I'm new with VBA, but after some research I entered this code in the AfterUpdate line in Properties:

    Private Sub CancelDate_AfterUpdate()
    If Me.txtCancel?.value = 1 Then Me.txtCancelDate = Now()
    End If
    End Sub

    It doesn't work...

    Can anyone help me?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    place the code in the txtcancel_after update event
    what you are doing here is setting the value of canceldate after its changed, whereas Im guessign you want to set a date/time value if the cancel checkbox/flag/whatever changes
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    As healdem said, the code would normally go in the txtCancel?_AfterUpdate event, not the AfterUpdate event of CancelDate. But your comment

    Quote Originally Posted by Maturin View Post

    ...On the form I use an action button for "Cancel?"...
    concerns me. Are you saying that you set the Value of txtCancel? by clicking a Command Button? If so, it is being set through code, and most events for txtCancel?, including its AfterUpdate event, will not fire! These events only execute if the data is changed physically, i.e. through the keyboard, scanner or by pasting data in. In these cases you have to explicitly Call the AfterUpdate event.

    Also note that 'yes,' in a Yes/No Field would be

    -1

    So instead of

    If Me.txtCancel?.value = 1

    your code should be

    If Me.txtCancel?.value = -1

    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

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    actyually rather than use a number you would be better off using hte intrinsic constants
    vbtrue / vbfalse
    or
    true / false
    I'd rather be riding on the Tiger 800 or the Norton

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
  •