Results 1 to 9 of 9
  1. #1
    Koolaid is offline Novice
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Location
    Northern VA
    Posts
    26

    I want to populate a date field (by 6 months) automatically when form is opened

    So, this is probably not that hard but I am very new at this. Literally a few days new lol

    I have two fields for dates.

    Start date and Expiration date

    I already figured out how to auto populate the Start Date with today's date when I open my form.

    What I want is that when it opens, it also auto updates the expiration date automatically to 6 months from the Start Date.

    I'm sure this is something that is common but I have no idea how to do it. I am assuming there is a built-in functionality that I can use to say for example:

    180 days from THIS field(Start date) = the (expiration date)

    automatically

    Thanks for the assistance in advance.

    Koolaid

  2. #2
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    https://support.office.com/en-us/art...4-61e8c57afc19
    this should help, its pretty simple. you can also check google for "access dateadd" if it gives you any trouble there are plenty of referances for help. good luck

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Not that you would have instinctively known that what you needed was a function, but if you're going to dabble further, I'd recommend you bookmark this page (I have).
    http://www.techonthenet.com/access/functions/
    Browse through it and you'll get a feeling for what functions can do, and when you're faced with a similar need in the future, you might remember that you saw something there that you can use.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Koolaid is offline Novice
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Location
    Northern VA
    Posts
    26
    I appreciate the pages you guys hooked me up with. The issue is, since I have the first field auto dating to always today's date, how would the second field know that I always want it to be 3 years from that field? Do I add that field name? or is it some special thing I have to add in.

    Also, where am I adding this stuff...In the table view...or the form view? etc. Sorry I know I am very green lol
    Thanks

    Koolaid

  5. #5
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    if you are not used to using a little code probably the easiest is to use the control source of the second text box or the query of the recordset. this should answer the how.
    http://www.techonthenet.com/access/f...te/dateadd.php

  6. #6
    Koolaid is offline Novice
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Location
    Northern VA
    Posts
    26
    Thanks. I will check it out and give it a try. I'll let you guys know how it turns out lol

  7. #7
    Koolaid is offline Novice
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Location
    Northern VA
    Posts
    26
    Ok guys...I was able to ensure that two fields are auto populated from the default value area using Date() for the Start Datefield and DateAdd("m",6,Date()) for the Expired field. This is great for that first time setting things up. But when that 6 months runs out and that same user needs a new date for the start date...how can I make that other field called Expired auto update when I choose the new date, to be 6 months from that without having to type anything? Thanks guys!

    I understand I can use queries to do searches for things that can expire, are expired, etc. But I am mainly talking about from the data entry point of view, making this as automated as possible. Then once I have this set up I can then work on setting up a query to find records based on being a month out from the Expired date field, etc.
    Last edited by Koolaid; 03-15-2016 at 09:58 AM. Reason: Added some more info

  8. #8
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    without having to type anything?
    Type in where? The calculated value should always be the current date and the expired date 6 months later. You posted the expression that calculates this but left off the part that shows what it is being applied against. If that's the name of the control that holds the start date, which defaults to today, I presume you're allowing the user to enter a new 'start date' and you want to update the expired date. In that case, you don't seem to realize that from moment that you open a database, for anything that goes on, there is likely an event for that - including the opening of the db itself. Most events are listed in the property sheet for any object within the db. You should be able to learn what each does simply by pressing the F1 key, as a starting point for making a choice. Likely what you need is the After_Update event for when the user enters a new date in the 'start date' field, if I understand what you're doing. As I just said, it should be a simple matter for you to decide why you'd use that event over the On_Change event, for example.

    Knowing of the event is only a small part of the battle. The rest requires that you understand how to code for what you want to happen, or at least be able to ask a targeted question if you don't find a suitable example on the many, many web page sources out there. In your case I suspect you'd need this in the after update event for your control:

    Me.NameofExpiredControl = DateAdd("m",6,Me.NameOfStartDateControl)
    Me.Refresh
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  9. #9
    Koolaid is offline Novice
    Windows 8 Access 2016
    Join Date
    Mar 2016
    Location
    Northern VA
    Posts
    26
    Yes, you are right that when I want to edit that start date later on I want the expired to auto update by 6 months without needing to do anything else. The way I have it now, each column just auto adds today's on Start date and the expire field is 6 months from today's date when the new record is created. They are not technically linked in anyway. If I alter the Start Date field after the fact, nothing happens to the expired date. That's what I'm trying to do though...have them linked so it's easier to auto update based on what is done to the Start date field. Thanks a lot. I'll check it out tomorrow once I go back to work.

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

Similar Threads

  1. Replies: 5
    Last Post: 07-02-2015, 10:49 AM
  2. Replies: 13
    Last Post: 06-11-2015, 06:41 PM
  3. Replies: 3
    Last Post: 02-23-2014, 02:06 PM
  4. Automatically populate expiration date
    By Tyler in forum Access
    Replies: 2
    Last Post: 01-10-2014, 10:05 AM
  5. Replies: 21
    Last Post: 08-29-2013, 11:08 AM

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
  •  
Other Forums: Microsoft Office Forums