Results 1 to 7 of 7
  1. #1
    Cobbler is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    4

    Recurring data (date) in form

    I have a form for daily data entry into a table. The date field of this table would normally be populated with the previous day's date but not always. I want to be able to set the date at the beginning of the data entry session and not need to re-enter it with each line.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Have you tried storing the date that you set at the start of the session in a date variable and then each time you go to a new record populate the date field using the date in your date variable?

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    On your data entry form have an unbound text box with the date you want (you can set the default to date()-1 to get yesterday's date). Then whenever a new record is added have it inherit the value in the unbound text box.

    For instance let's say you have a form where you're entering hours worked for people on a given day.

    On this form you would have a unbound text box called CurrentDay with adefault value of date()-1. On this form you would also have a bound textbox with the name/datasource of WorkDate which would have a combo box with employee names and an employee ID (primary key field), after an employee name is chosen (and the pirmary key is stored), you can have in the ON EXIT event:

    Workdate = CurrentDay

    and any time you leave the employeeID field your workdate will be populated with the value from the unbound text box

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    rpeare,

    I think Cobbler wants the option to set the Date at the start of the session.
    It is not always going to be Date() -1.

    The other thing I wondered about was that on a Monday - would Cobbler want Sunday's date - or Friday's?
    That isn't mentioned in Cobbler's post but it crossed my mind.

    If that IS a requirement then this might work:

    Code:
     
    'Access 2010.
    If Weekday(Date) = 2 Then      'Uses default Sunday as Day 1.
        Workdate = (Date - 3)
    Else
        Workdate = (Date - 1)
    End If
    Either way - It sounds like what is required is the option to set the Date at the start of the session.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Which is exactly what my proposed fix does :P

    Set the date once, optionally setting a default date, but allow it to be changed and any new records that are added inherit the date entered the one time.

  6. #6
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Using your fix -the user either uses the default in Text Box 'CurrentDay' - Date()-1 - or enters an alternate date in the Text Box 'CurrentDay'?

  7. #7
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    The user sets the value of CurrentDay. When the form opens that can default to today's date minus one, but the user can modify it to whatever they want. When a new record is added (required fields are present) the CurrentDay field can be copied to the WorkDate field (assuming of course workdate is a bound field)

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

Similar Threads

  1. Replies: 30
    Last Post: 06-26-2011, 10:47 PM
  2. Sum by date keep data
    By ashbear in forum Queries
    Replies: 2
    Last Post: 05-09-2011, 01:00 PM
  3. Generating Recurring Tasks.
    By Jamesamorris in forum Access
    Replies: 3
    Last Post: 10-26-2010, 10:46 AM
  4. Replies: 1
    Last Post: 07-07-2010, 04:22 PM
  5. set date field on form to date variable
    By laavista in forum Access
    Replies: 3
    Last Post: 06-28-2010, 03:03 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