Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Aug 2008
    Location
    Daytona Beach, Florida, USA
    Posts
    42
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Add 1 day to Date Field in a form

    I have a form that includes a date field (input mask: 00/00/00;0;_;0 and would like to have it add a day when you add a new record from the previous record. Not sure if there is a way to do this using a macro.

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    Adding a day to a field containing dates is fairly simple - you can use the DateAdd() function, or you can simply use arithmetic to add 1 to the field. The latter works because of the way dates are stored in Access. However adding a day to a value from a previous record can get tricky - in general on a form the values from another record are not available to you. Is your form a continuous form where you can see other records? Also, is the sequence of records always consistent, in other words are the records sorted in a consistent fashion when they are displayed on the form?
    Wendell

  3. #3
    New Lounger
    Join Date
    Dec 2009
    Location
    Orange County
    Posts
    14
    Thanks
    1
    Thanked 0 Times in 0 Posts
    However adding a day to a value from a previous record can get tricky - in general on a form the values from another record are not available to you.
    In my opinion, that's where Access local and global variables are so darn handy! I use them extensively. For example, I use a global variable within simple application log in procedures to store the name of the person using the Access app and then update database records they have created/changed with this information (also adding date & time).

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Here is a thread asking a very similar question. In that thread the aim was to carry the same value to a new record. You would need to add 1 to it.
    Regards
    John



  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts
    Quote Originally Posted by rodgerbeard View Post
    In my opinion, that's where Access local and global variables are so darn handy! I use them extensively. For example, I use a global variable within simple application log in procedures to store the name of the person using the Access app and then update database records they have created/changed with this information (also adding date & time).
    Personally, I'm not a big fan of relying on global variables. It is too easy to have them get blown out. I'll use them in only in short-term situations. For things like who is current user, I'd rather rely on a control on a hidden form or a hidden control on a form that is always open (like my menu).
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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