Dcount still returns a value

Lesceline Gibson

Well-known Member
Joined
Apr 6, 2012
Messages
753
Hi Lovely people

I am trying to look at a table field in access to see if todays date exists in a column, if it does then dont run else continue however even thoigh the date doesnt exist - it still returns it as found - Please tell me whats wront with this code?

If DCount("Date_Ran", "tbl_Log", Int(Now)) > 0 Then
MsgBox "DB Has Already Been Updated"
Exit Sub
End If
 

Some videos you may like

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

JonXL

Active Member
Joined
Feb 5, 2018
Messages
302
Office Version
365, 2016
Platform
Windows
VBA Code:
DCount("*", "tbl_Log", "Date_Ran = #" & Date() & "#")
 

xenou

MrExcel MVP, Moderator
Joined
Mar 2, 2007
Messages
16,601
Office Version
2013
Platform
Windows
Probably also:
VBA Code:
If DCount("Date_Ran", "tbl_Log", "DateRan > Int(Now)") > 0 Then
The main thing is that the third argument must be a WHERE clause without the WHERE keyword, not just an integer.
 

Forum statistics

Threads
1,089,220
Messages
5,406,925
Members
403,113
Latest member
ms_excel_recal_or_die

This Week's Hot Topics

Top