findfirst weird behavior with date field

unknown2u

Registered User.
Local time
Today, 11:50
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
 
Is the "date" field defined as date type in the table or is it actually a text field.
 
It is defined as a date type and I use the corresponding delimiters - #
 
what is your regional setting for date, is it mm/dd/yyyy? try formatting your date.

[datefield] = #" & Format(yourCriteriaDate, "mm\/dd\/yyyy") & "#"
 
As I wrote, I already tried formatting it and even tried changing the field format but i always got the same result..
 
Post you database with some sample data + a description how to reproduce what you write about.
 
That might be a problem.
I'll post an example of it later today if there's no other way..
 
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

Back
Top Bottom