473,508 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date problem: day/month getting switched on filter

7 New Member
Hi everyone,

I have a weird problem, and I cannot work out what's going on.

I have a continuous form (frmEnterCosts) based on a query (qryEnterCosts). I have series of unbound combo boxes to filter various fields on this form, one of which (cboFilterPackingDate) filters the field 'PackingDate', which is a Date field.

There is a command button which takes the contents of each combo box to build the filter string and then applies the filter when it is pressed.

The piece of code within the OnClick event concerning the PackingDate is:

Expand|Select|Wrap|Line Numbers
  1. If Not Me.cboFilterPackingDate.ListIndex = -1 Then
  2.   strPackingDate = "[PackingDate] = #" & Me.cboFilterPackingDate & "#" & " AND"
  3. Else
  4.   strPackingDate = ""
  5. End If
My problem is that it doesn't seem to be handling the date correctly. If the date is something like 13/08/2010 (i.e. 13th August) which cannot be confused with another date (i.e. 8th of 13th Month doesn't exist), the filter works fine. If the selected date is, say, 05/07/2010 (5th July), it will filter for 07/05/2010 (7th May). And if the 'reverse' date does not exist in the data, it returns nothing.

I have put the filter string into a text box to see what's happening, and the filter string has the correct date (i.e. matches the combo box) it just filters the wrong date, and I cannot for the life of me figure out where its going wrong. There is nowhere in the database where the date is stored in the U.S format.

I've used Format in the code to try and force it, but I don't think this is the problem.

I would be grateful for any pointers as it's driving me a bit mad!

Thanks

Neil
Aug 28 '10 #1
3 6453
Neil Chinneck
7 New Member
Just to update:

If I open the form and filter on a date (16/09/2010) from the PackingDate field manually, then look at the filter, it looks like this:

((qryEnterCosts.PackingDate=#9/16/2010#))

So I could probably get around it by switching the day/month around in my code, but I do not see why it should be treating the date like this when it filters?

Thanks

Neil
Aug 28 '10 #2
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Neil. The problem is that Access is actually interpreting date literals in the ANSI-standard way, which is indeed mm/dd/yyyy. It is switching the day and month where it is clear that the regional setting is applying, but leaving them where the regional setting can be interpreted as a valid mm/dd/yyyy date.

All is not lost, though, as all you need to do is to force the format of the date to the ANSI mm/dd/yyyy form and all should be well.

Replace line 2 above with:
Expand|Select|Wrap|Line Numbers
  1. strPackingDate = "[PackingDate] = " & Format(Me.cboFilterPackingDate, "\#mm/dd/yyyy\#") & " AND"
We have an Insights article on Literal date-times and their delimiters which explains why all this occurs.

-Stewart
Aug 28 '10 #3
Neil Chinneck
7 New Member
Thanks very much for the reply; it seems like an odd thing for Access to do, but I guess I'll have to live with it.

Thanks
Aug 30 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
3715
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB...
3
6287
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When...
2
2064
by: Danny | last post by:
Hi I'm using asp.net , visual studio.NET 2003 , c#. I have a problem that occurred only on my computer And not on other developer's computers. My CultureInfo.CurrentCulture is "he-IL" But when...
1
1259
by: David | last post by:
Hi, I have a problem in getting the status of the modem. Here is my code: HANDLE hfile; DCB dcb; hfile = CreateFile("BCM V.92 56K Modem", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); ...
5
2277
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
0
1017
by: arlene5781 | last post by:
Hi Guys, please help.. Im having a problem in getting the Handle/Process ID in a existing application. Here's the existing code, i wonder how to get the &H4D7 and 1242. Do you have a tool for this?...
0
1566
by: sandeepk84 | last post by:
Hi all... I am facing a problem in getting attachments from Yahoo Classic using JavaMail. My program reads the attachments from gmail and Yahoo Beta. But attachments of type pdf or txt from...
0
979
by: sejal17 | last post by:
Hello everyone, i have a problem with getting a print out of iframe in asp.net with language c#. an iframe contain a data from diffrent page(docoment1.htm). can any one help me in this...
1
3155
by: naveenkongati | last post by:
Hi, How do we fetch only date and month from date column (Ex: 2008-11-10) in Mysql? Thanks
3
1929
by: vtpvp82 | last post by:
I am having problem in getting response from remote server for that I have written following script response got correctly but the data on the page is not displayed it gives “–“ in place of grid...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.