How to count duplicated date
Jon,
Try SQL instead of the Dcount.
Dim db as Database
Dim rs as Recordset
Dim strSQL as String
Set db = CurrentDb
'Set up SQL string . Note the format for date fields in Access -
#01/01/2008#
strSQL = "SELECT COUNT(*) AS DateCount FROM MyTable WHERE ndate = #" &
Me!MyField & "#"
Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If rs.Recordcount = 0 Then
MsgBox "Date Not Found"
Else
MsgBox "Date Found. Number of occurances is: " & rs!DateCount
End If
Set rs = Nothing
Set db = Nothing
"Jon" wrote in message
...
Greeting,
I have table and it has field for date and it has too many duplicated
date.
I have unbound form and it has unbound textbox.
What I want to do is input a date in the textbox and click on command
button
after that access will matching the input date with the records and if
there
are duplicated date will give the total number of them.
I use the following code but does not work
Dim dd As String
dd = Nz(DCount("[ndate]", "[dd]", "[ndate]=" & (Me.aa)), 0)
MsgBox dd
Any help please??
|