Solved

weird date filtering

Posted on 2012-12-25
21
250 Views
Last Modified: 2012-12-30
hey guys, i've got these lines of code and the funny thing is that when my

txtServicingWorkHoursStartDate = "28 nov"
txtServicingWorkHoursEndDate= "30 nov"

it works fine.

but if i change my txtServicingWorkHoursEndDate to anywhere between 1 dec to 11 dec it doesn't work. meaning no records shown - even the ones from 28 to 30 nov which was showing properly previously. even if i use 01 dec or 1 dec 2012 or 01 dec 2012. this is quite strange. any possible explanations?

Forms!frmMTKManager.subfrmServicingWorkHours.Form.Filter = "[CalendarDate] >= #" & DateValue(Me.txtServicingWorkHoursStartDate) & "# AND [CalendarDate] <= #" & DateValue(Me.txtServicingWorkHoursEndDate) & "#"
    Forms!frmMTKManager.subfrmServicingWorkHours.Form.FilterOn = True
    Forms!frmMTKManager.subfrmServicingWorkHours.Form.AllowFilters = False

btw datevalue is giving me the correct dates - i've tested it with ?month(DateValue(Me.txtServicingWorkHoursEndDate)  in the immediate window. thanks guys!!

update - it gives me the same problem for the start date. if i put the start date as anything before 1 dec to 11 dec it works fine.

start date 12 dec and end date 12 dec gives me records for 12 dec. when i change start date to 11 dec bham! i get records from 26 oct to 12 dec. so weird!!!! (compacting and repairing the database doesn't help as well!!)
0
Comment
Question by:developingprogrammer
  • 11
  • 9
21 Comments
 
LVL 22

Expert Comment

by:Flyster
ID: 38720602
Is your data just from this year or do you have data from previous years? The date value of 11/30/12 is 41243. For 2011 it's 40877. That could make the difference.

Flyster
0
 

Author Comment

by:developingprogrammer
ID: 38720607
it's just this year, but even when i put in the year dd mmm yyyy format it still doesn't work
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720613
Is the field CalendarDate in your table a Date data type or a Text data type?  It should be the former.
0
 

Author Comment

by:developingprogrammer
ID: 38720617
it's already date / time in the underlying table = (
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720620
Try this format - 12/11/2012 to 12/12/2012 and see what the result is.
0
 

Author Comment

by:developingprogrammer
ID: 38720623
same result = ((
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720626
Can you upload a copy with just the problem forms and table?  Just remove any private information first.
0
 

Author Comment

by:developingprogrammer
ID: 38720648
hey irogsinta so sorry my database is all so tightly coupled that removing all the data or just taking out the tables / queries would be so difficult. instead i captured all the screenshots and here it is in the zip file. do let me know if you want to see other tables / queries / forms / code
Database-Screenshots.zip
0
 

Author Comment

by:developingprogrammer
ID: 38720653
irogsinta how bout using the criteria of the QBE? could you help me correct my syntax if it's wrong? not sure why i can't get this query to work. thanks!!
QBE.png
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720683
I don't think I could be of much help with just these screenshots.  Although, from the screenshot of your form, I would recommend that you add a date format property to your textboxes so that the user can select a date from the popup calendar instead of typing a date.  That way the format is consistent.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720701
As for your question on the syntax in QBE, that's not right.  It should be
<= Forms!frmMTKManager!txtServicingWorkhoursStartDate

The name of the tab control is not part of syntax in referring to a control in one of its pages.
0
 

Author Comment

by:developingprogrammer
ID: 38720712
great irogsinta!! i managed to extract the tables and forms with some help. the problem lies in mtk manager work hours tab. here's the access database!! = ))
Query.mdb
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720725
It seems to work fine with these dates:
screenshotCapture.JPG
0
 

Author Comment

by:developingprogrammer
ID: 38720744
yup yup, i understand, but when i put any date from 1 - 11 dec it doesn't work just like the previous post.

here are the screenshots
problem.png
ok.png
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 500 total points
ID: 38720755
Strange, it seems to work fine:
screenshot
0
 

Author Comment

by:developingprogrammer
ID: 38720756
Crap... I'm in trouble then = (( what do I do?? = ((
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720758
Do you have another system you can try your database on?
0
 

Author Comment

by:developingprogrammer
ID: 38720765
I don't right now but I need to get it to work on my computer. Is there anything I can do to troubleshoot this?
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38720771
Try the query.mdb database you uploaded.  Does it work there?  If so, then you may want to try copying all your objects to a new database and see if that takes care of the issue.
0
 

Accepted Solution

by:
developingprogrammer earned 0 total points
ID: 38720787
hrmm irogsinta i downloaded the mdb i uploaded and it still can't work. i ended up using the query QBE criteria to do the query (i had the create another instance of the query cause the previous one couldn't have parameters). really not sure why mine couldn't work but i really appreciate all your time and effort!! = ))

>=[Forms]![frmMTKManager]![txtServicingWorkHoursStartDate] And <=[Forms]![frmMTKManager]![txtServicingWorkHoursEndDate]
0
 

Author Closing Comment

by:developingprogrammer
ID: 38730577
my solution was only a workaround - didn't fix the main problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 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

24 Experts available now in Live!

Get 1:1 Help Now