Results 1 to 10 of 10
  1. #1
    bishop0071 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    24

    Display date ranges in subform

    I have tblWO_Points and that is included in frmClients as a subform, frmClientsSubform. I have a Date_WO field that list dates (Monday, January 1, 2013) I would like to add a form control within frmClients, where I can have a first date and second date range. I would like it so that my date ranges will always be default for the Saturdays as first date range and Fridays as second date range. Currently my frmClientsSubform list all the dates for each client.

    First Date: Saturday, January 19, 2013


    Second Date: Friday, January 25, 2013

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You have text field with value like 'Monday, January 1, 2013'? Why not a date/time field with 1/1/2013 value? If you want data treated like a date, should be in a date/time field and stored as a date value. Then there are functions specifically for working with date values.

    To calculate the date of Saturday for the current week:

    Date()-WeekDay(Date(),vbSaturday)+1

    Date of Friday for the current week:

    Date()-WeekDay(Date(),vbSaturday)+7
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bishop0071 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    24
    They are date/time fields. Sorry did not mean to confuse you about that. How do I set those formulas in the frmClients so it brings up those dates in the frmClientsSubForm?

    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You can use those expressions in the DefaultValue property of control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bishop0071 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    24
    Can't get it to work. Keep getting #Name? error

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, will have to use 7 in place of vbSaturday.

    vbSaturday is a constant for use in VBA procedures.

    Date()-Weekday(Date(),7)+1
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    bishop0071 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    24
    The dates shows Saturdays and Fridays as default but in the subform it still shows dates for all records. Also when I change the first date it will still show the first date of the record but the second date comes out correct.

    Example: If I put in 1/18 as first date the first record in subform always appear which starts at 1/14.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The DefaultValue property will populate field when initiating a new record. Don't understand what you mean by 'it still shows dates for all records'? Don't understand what you want to do. Please describe in detail the behavior you want.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    bishop0071 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    24
    When I open the frmClients I want to see Saturday-Friday records in the subform if there are any. Under a Field2 I am only allowing them to accumulate 16 points max. So instead of creating date search fields where I have to pick Saturday and Friday dates every time I look at a new record.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You want to use these date values as criteria to retrieve records that fall within the two dates?

    If you want form to display only records meeting those date criteria, then must apply those dates as filter criteria. Several ways to accomplish:

    1. Put parameter in query used as form RecordSource in criteria row under date field: BETWEEN Date()-Weekday(Date(),7)+1 AND Date()-Weekday(Date(),7)+7

    2. Put the criteria in form Filter property: [fieldname] BETWEEN Date()-Weekday(Date(),7)+1 AND Date()-Weekday(Date(),7)+7

    3. For dynamic filtering, have UNBOUND textboxes in form Header section for entering date values, DefaultValue property can populate the textboxes. Code in button Click event to execute filter
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Searching for Date Ranges
    By phd42122 in forum Access
    Replies: 2
    Last Post: 05-07-2012, 07:20 AM
  2. Working with date ranges
    By Acegundam in forum Queries
    Replies: 3
    Last Post: 11-04-2011, 02:04 PM
  3. Date ranges using Calendar control
    By LilMissAttack in forum Forms
    Replies: 8
    Last Post: 08-25-2011, 10:04 AM
  4. Select Query Using Different Date Ranges
    By Hemi426 in forum Queries
    Replies: 3
    Last Post: 07-26-2010, 01:06 PM
  5. summing values associated with date ranges
    By wdemilly in forum Reports
    Replies: 0
    Last Post: 07-17-2009, 01:53 PM

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