DCount Help

Heatshiver

Registered User.
Local time
Tomorrow, 00:36
Joined
Dec 23, 2011
Messages
263
I have a field and a button that allows the use to put in a new date, click the button, and create a new record with that new date.

When the button is clicked the following DCount VBA is implemented:

If DCount("[UserID]", "tblGenSum", "[UserID]= '" & Me.UserID & "' And [Days]= #" & Me.txtNewDate & "#") > 0 Then
MsgBox "This user has already used this date."
Me.txtNewDate.Value = ""
Exit Sub
End If


So if the same UserID is and date has already been used, the message is meant to display and exit sub.

My problem is that it will not do this, as it will add the same date already used previously.

What am I doing wrong and how can I fix it? Thanks for the help.
 
A while back I discovered that the Domain Aggregation functions can produce some unexpected results when using date criteria, the discussion here may help you solve your current issue.
 
Is your UserID a number or a string data type, if a number then your syntax around Me.UserID is as for string values, should be " & Me.UserID & "
David
 

Users who are viewing this thread

Back
Top Bottom