findfirst weird behavior with date field (1 Viewer)

unknown2u

Registered User.
Local time
Yesterday, 16:31
Joined
Oct 16, 2013
Messages
46
I wrote a simple code to check for three values of three different fields in a form and find a record in a table if they match - I did it by using the findfirst method and checking for three criterias connected with "And".

So for example if fieldA = x, fieldB = y and fieldC = w,
open tableA and find a record where these three fields are equal to other three fields.

It works great the probelm is one of the fields is a date field and behaves really strange...
When the date is something like 12/11/2015 it works fine but once it's 11/11/2015 or 10,09,08,07/11/2015 it doesn't find it and thinks it doesn't exist.

I though it had something to do with zeros but I can't be certain since it happened with 11 as well.
I tried the code without comparing the date field and it's fine.

Something messes with the way access interperts the date..I've tried using Format, CDate but it didn't change anything.. always certain dates are being ignored..

Any clue as to what might cause this?
The code itself is very simple just one line of findfirst..

Btw I tried displaying what date it finds when the code doesn't work and it always gets stuck on one record with something like 08/09/2014...

Thanks in advance
 

bob fitz

AWF VIP
Local time
Today, 00:31
Joined
May 23, 2011
Messages
4,729
Is the "date" field defined as date type in the table or is it actually a text field.
 

unknown2u

Registered User.
Local time
Yesterday, 16:31
Joined
Oct 16, 2013
Messages
46
It is defined as a date type and I use the corresponding delimiters - #
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:31
Joined
May 7, 2009
Messages
19,249
what is your regional setting for date, is it mm/dd/yyyy? try formatting your date.

[datefield] = #" & Format(yourCriteriaDate, "mm\/dd\/yyyy") & "#"
 

unknown2u

Registered User.
Local time
Yesterday, 16:31
Joined
Oct 16, 2013
Messages
46
As I wrote, I already tried formatting it and even tried changing the field format but i always got the same result..
 

JHB

Have been here a while
Local time
Today, 01:31
Joined
Jun 17, 2012
Messages
7,732
Post you database with some sample data + a description how to reproduce what you write about.
 

unknown2u

Registered User.
Local time
Yesterday, 16:31
Joined
Oct 16, 2013
Messages
46
That might be a problem.
I'll post an example of it later today if there's no other way..
 

unknown2u

Registered User.
Local time
Yesterday, 16:31
Joined
Oct 16, 2013
Messages
46
Ok I finally managed to find a solution.
I tried formatting it to dd/mm/yyyy but i didn't work so i just changed it to -
FindFirst "[TableFieldA] = " CLng(formFieldA)
and it worked perfectly!

Thanks anyways ��
 

Users who are viewing this thread

Top Bottom