Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wierd DCount issue. Someone please enlighten me. 1

Status
Not open for further replies.

Kennelbloke

Technical User
May 22, 2015
32
AU
I have a bit code that checks to see if a client has two or more records in a query and shows a different form based on the result. Simple enough. It works most of the time fine.

However, occasionally it doesn't work and returns zero count even through there are records in the query. Example:

The me!Date field is set to the dates shown in the query in both instances

Screenshot_2022-11-14_134105_wcyndc.png


chkDupe returns 0 records

I even tried hard coding the date

3rd_Screenshot_2022-11-14_145657_ifwqkc.png


chkDupe also returns a count of 0 records

The underlying query has these records.
Screenshot_2022-11-14_134014_caeygb.png


On another client
2nd_Screenshot_2022-11-14_143723_hufhxm.png


chkDupe Returns 2 records
2nd_Screenshot_2022-11-14_143817_pcs49j.png


It's date related because if I remove the date part of the criteria it returns correctly. The underlying field is set as a Date field in short format.

If I copy the query and create a play one and enter the criteria I get the correct result of 2 records.

I may be going senile but...
 
Access first try to interpret date from #aa/bb/ccc# as mm/dd/yyyy, it is your first case. If it is not a valid string, the next attempt is dd/mm/yyy (second case).
You can try unambigious ISO format #yyyy-mm-dd# instead, some tips from MS here.

combo
 
Hi Combo

Funny how the dd/mm/yyyy format works on 99.999% of the 1000+ records but just not on a few. Anyway I tried your suggestion and it still didn't work (hmmmm...).

I have just created DAO solution and that seems to work with either the dd/mm/yyyy or the mm/dd/yyyy format. Go figure...

So I'll leave it at the DAO and mm/dd/yyyy format and move on.

Thanks for your time and suggestion.

Cheers
 
My system date setting is d/m/yyyy. I created simple table 'tDates' with dates of all October days in 'dtDate'. Simple
Code:
Sub test()
    MsgBox DCount("*", "tDates", "dtDate IN (#1/10/2022#, #15/10/2022#, #2022-10-03#)")
End Sub
returns 2, #1/10/2022# is interpreted as Jan. 10, 2022, not in the table, other dates are counted as expected.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top