Results 1 to 7 of 7
  1. #1
    melb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    12

    Creating Range of Dates in a Form

    I had a table where I entered in days employees had off along with the reason behind their absence. Previously I would manually enter each day and the reason in the table to record the information. Today I created a form to enter this information in using Form Wizard. I was wondering if there is a way to make the form populate numerous days at the same time. If someone is taking a week vacation I would want to be able to enter in the date their leaving and the date they are back and have the form create for instance 7 entries for the individual days that person will be gone along with the same information of why they are not there for each day.

    Is this possible? If so, what is the best way of going about doing this?

    Thanks

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    It is possible. It is not recommended as a design concept because those days are calculate-able from the Start and End date fields. One would need to write a loop code to find minimum date then apply a +1 to write it in while doing a compare to the maximum date and repeating until one reaches maximum date.

  3. #3
    melb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    12
    Currently I do not have start and end date fields, just a single date field which is the date they have called off. If I did place a start and end date field, how would I make it populate 7 table entries for the 7 days of the week with the data on each field rather than simply listing for instance 7/11/2015 as start date and 7/18/2015 as the end date.

  4. #4
    melb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    12
    So is it necessary to create a new field in the form? As now it's simply a singular date which I input manually each date an employee misses. So instead of DateMissed it would be BeginDate and EndDate for the range of days that are missed due to a vacation or other circumstance

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So is it necessary to create a new field in the form?
    Just to be clear on terminology: Tables have fields - Forms have controls.

    Some things to think about:

    You would need a button to execute the code and 4 unbound controls on the form:
    1) Some way to select the employee
    2) A start date control
    3) An end date control
    4) A reason control

    The code would need to check:
    if the EndDate > StartDate.
    if both controls have valid dates
    if only a date in the StartDate control, should only create one entry (ex. take 1 sick leave day)
    if the Reason control has an entry. (is the reason required?)

  6. #6
    melb is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2015
    Posts
    12
    Quote Originally Posted by ssanfu View Post
    Just to be clear on terminology: Tables have fields - Forms have controls.

    Some things to think about:

    You would need a button to execute the code and 4 unbound controls on the form:
    1) Some way to select the employee
    2) A start date control
    3) An end date control
    4) A reason control

    The code would need to check:
    if the EndDate > StartDate.
    if both controls have valid dates
    if only a date in the StartDate control, should only create one entry (ex. take 1 sick leave day)
    if the Reason control has an entry. (is the reason required?)
    Thanks ssanfu.

    As it stands I have a selection box with a list of employees, a date control, and a reason control. So all it was lacking was an end-date control. I put one in and it creates an entry in my table that will say something like:

    Name StartDate EndDate HoursMisssed Reason
    Adam Jones 3/3/2014 3/10/2014 7 hours Vacation Day Approved in Advance

    Rather than the desired result which is:
    Adam Jones 3/3/2014 7 hours Vacation Day
    Adam Jones 3/4/2014 7 hours Vacation Day
    Adam Jones 3/5/2014 7 hours Vacation Day

    and so on.

    Your post was very helpful, but I'm still a bit ambiguous on how to go about getting entries of individual dates being recorded after entering a StartDate and EndDate. Is there a terminology of what I'm trying to achieve so I can easily look it in the index of a book on Access or online without asking tedious questions here? I've tried "getting date range into individual entries on access" and a few similar searches and they don't seem to achieve what I'm looking for.

    Thanks!

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here is an example dB. I don't know your table name or your field names, so you will have to edit the code.
    The is no error handler, so be warned! Just an example of how the code might look.

    (in Access 2010)

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

Similar Threads

  1. Add a range of dates to a table
    By gemadan96 in forum Programming
    Replies: 3
    Last Post: 06-20-2014, 01:49 PM
  2. Out of range error when creating a form
    By marcvanderpeet12 in forum Forms
    Replies: 1
    Last Post: 05-10-2013, 12:22 PM
  3. Creating a Date Range Form
    By daniejm in forum Forms
    Replies: 1
    Last Post: 12-13-2012, 08:51 AM
  4. Query input dates for range of dates in two fields
    By kagoodwin13 in forum Queries
    Replies: 3
    Last Post: 02-13-2012, 04:25 PM
  5. creating records from integer range in a form
    By archzealot in forum Forms
    Replies: 8
    Last Post: 04-05-2010, 12:45 AM

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