Solved

filtering for date period

Posted on 2012-12-24
4
379 Views
Last Modified: 2012-12-25
hey guys,

anything wrong with my this line of code?

Forms!frmMTKManager!subfrmServicingWorkHours.Filter = "[CalendarDate] >= #" & Format(Me.txtServicingWorkHoursStartDate, "m-d-yy") & "#"

gives me this error message 1
i want to filter the query from a certain date to a certain date = ) thanks guys!!
0
Comment
Question by:developingprogrammer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 400 total points
ID: 38718096
To refer to a filter on a subform you use this syntax..

Forms!mainFormName.subformcontainercontrolname.Form.Filter

subformcontainercontrolname is the name of the subform control on the Main form that holds the subform.  It might have the same name as the subform it contains, but it could be different depending how it got there.  But in any case it is the name of that container control that is used.  The name of the subform is not relevant.
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 25 total points
ID: 38718709
In addition to what Peter said, if your code is on the main form itself, you can refer to it using the Me keyword.
Me.subfrmServicingWorkHours.Form.Filter =

Ron G.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 75 total points
ID: 38718721
Does this work?
Forms!mainFormName.subformcontainercontrolname.Form.Filter = "[CalendarDate] >=" & "#" & Me.txtServicingWorkHoursStartDate & "#"
...If txtServicingWorkHoursStartDate is a real date, then the format should not really matter.


Finally the format you are specifying is outdated ("m-d-yy")
1. This format will produce different length dates for single/double digit Months and dates:
1/5/57
11/17/94
...as opposed to a more standard format of "mm/dd/yyyy", which will produce:
01/05/1957
11/17/1994

2. That old format also does not clearly indicate what year you are specifying.
Is a year of 25, ...1925 or 2025?

JeffCoachman
0
 

Author Closing Comment

by:developingprogrammer
ID: 38720576
hey peter, thanks!! it works like a charm! = )

ron, thanks, i knew we could use me to refer to the calling form but your bolding of the FORM word helped me spot the correct code i should use = )

thanks jeff! i always thought i had to put things in a certain format. now i know i don't need to so long as it's a real date. and yup i will bear in mind about the date format. thanks!!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question