Results 1 to 7 of 7
  1. #1
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53

    Only display records in subform that have a certain date.

    Hello I have a sub form that is connected to a query that displays week dates and the hours for that week.
    I was wondering if there is a way to only display the last week, the current week and all future weeks.

    So for example, the attached picture should only show the last four entries (01/06/2014 to 22/06/2014).



    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	12.3 KB 
ID:	16671

    Any help would greatly be appreciated.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Have you tried using the Form's .Filter property?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    On your form, have a box, txtThisWeek, that defaults to the current week.
    your query would have a where clause that looks to it (minus 7 days): where [week ending]>= dateAdd("d",-7, forms!frmMain!txtThisWeek)

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Would have to calculate the last day of the current week then subtract 14 days to establish filter parameter. Base the subform RecordSource on a query with that filter.

    You show dates in non-Access standard so you should review: http://allenbrowne.com/ser-36.html

    Try:

    [Week Ending]>(Date()-(Weekday(Date())-1)+6)-14
    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
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    On your form, have a box, txtThisWeek, that defaults to the current week.
    your query would have a where clause that looks to it (minus 7 days): where [week ending]>= dateAdd("d",-7, forms!frmMain!txtThisWeek)
    I know how to default to the current day, but how in the world do you default to the current week?

    And I made a mistake the form is not connected to a query but to a table so I can't put a where clause, unless of course I create a query based on that table then reconnect it to sub form.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Calculate the current week ending date. Suggestion in post 4. Use a query or subform Filter property.
    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
    zipaway is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    May 2014
    Posts
    53
    Quote Originally Posted by June7 View Post
    Would have to calculate the last day of the current week then subtract 14 days to establish filter parameter. Base the subform RecordSource on a query with that filter.

    You show dates in non-Access standard so you should review: http://allenbrowne.com/ser-36.html

    Try:

    [Week Ending]>(Date()-(Weekday(Date())-1)+6)-14
    Thank you so much for your help, this worked great.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-03-2014, 08:03 AM
  2. Show certain records only on subform
    By JayGee1969 in forum Forms
    Replies: 36
    Last Post: 09-13-2012, 07:37 PM
  3. Subform to show records of Listbox
    By gbmarlysis in forum Forms
    Replies: 5
    Last Post: 02-27-2012, 04:03 PM
  4. Show records for each date
    By cooper in forum Forms
    Replies: 2
    Last Post: 08-11-2011, 08:58 AM
  5. Show selected records in subform
    By Papilion in forum Forms
    Replies: 8
    Last Post: 06-18-2011, 07:41 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