Solved

filtering for date period

Posted on 2012-12-24
4
376 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 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

Suggested Solutions

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

896 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now