Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Posts
    7

    Unanswered: Input Today's Date in a Form Field when another Field changes

    I would like to automatically have today's date entered into a field when I change another fields content. For example, when a status changes in my Resolution_Status field the Resolution_Status Date field in populated with today's date.

    Appreciate suggestions and thoughts.

  2. #2
    Join Date
    May 2009
    Posts
    258
    Something like this might work:
    Code:
    Private Sub Resolution_Status_Change()
        On Error GoTo BeforeUpdate_Err
    
        ' Set bound controls to system date and time.
        Resolution_Status_Date = Date
    
    BeforeUpdate_End:
        Exit Sub
    
    BeforeUpdate_Err:
        MsgBox Err.Description, vbCritical & vbOKOnly, _
            "Error Number " & Err.Number & " Occurred"
        Resume BeforeUpdate_End
    End Sub
    Ax

  3. #3
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Use the AfterUpdate event of the control not the _change event;

    If you use the change event, the date will be set as soon as you type anything - If the user cancels their input, the new date will remain in place.

    The following assumes it is code behind a form with both controls on:

    Private Sub Resolution_Status_AfterUpdate()

    Me.ResolutionStatusDateWhateverName = Date

    End Sub
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  4. #4
    Join Date
    May 2009
    Posts
    7

    Thank you Ax

    Many Thanks Ax for your code. It did the trick.

  5. #5
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Agreed with Gareth.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

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