Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Bogangar NSW Australia
    Posts
    154
    Thanks
    29
    Thanked 3 Times in 2 Posts

    Question Access Forms - How to set field default value = to another field on form

    I have a form that I use to update a table. The form is used to record details of activities that generally start and finish on the same day, but not always. Accordingly I have two fields on my form: Start_Date and Finish_Date, and I would like Finish_Date to be automatically populated and only changed if the activity runs beyond the day it started.

    I would like to be able to set the Default Value for Finish_Date equal to the value entered in the Start_Date field and have tried setting the default value to =[Start_Date], but nothing happens.

    I'm guessing the solution is simple, but I just can't find it. Any help will be much appreciated.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,434
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Use the AfterUpdate event of the Start_Date field to set the value of Finish_Date.
    Code:
    Private Sub Start_Date_AfterUpdate()
       If Not ISNULL(Me.Start_Date)  Then
         Me.Finish_Date = Me.Start_Date
       End if
    End
    You may want to do additional testing to see if Finish_Date already has a value and then act accordingly.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    2 Star Lounger
    Join Date
    Dec 2009
    Location
    Bogangar NSW Australia
    Posts
    154
    Thanks
    29
    Thanked 3 Times in 2 Posts

    Access Forms - How to set field default value = to another field on form

    Many thanks RetiredGeek, just the solution I needed

  4. #4
    Star Lounger
    Join Date
    Mar 2011
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am also learning VBA for MS Access.
    this helps my learning.
    Thanks!

Posting Permissions

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