?
Solved

filtering for date period

Posted on 2012-12-24
4
Medium Priority
?
390 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
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 1600 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 100 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 300 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

839 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