?
Solved

filtering for date period

Posted on 2012-12-24
4
Medium Priority
?
381 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 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

765 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