Simple DCount Help Please

ddrew

seasoned user
Local time
Today, 22:47
Joined
Jan 26, 2003
Messages
911
I am trying to count the amount of records in a table and see if the number is greater than 0, if it is then I want a message box stating how many records there are. This is my code the problem is that I cant get it to count correctly and have no idea how to get the value, (when correct) into the message box.


Code:
Private Sub Count_Click()
    Dim OpenRecordCheck As Integer

        'Check to see if there are any open incidents
         
        OpenRecordCheck = DCount("[ID]", "[Table1 Query]", [Tick] = "'True'")
        If Count > 0 Then
            MsgBox ("Count")
        End If

End Sub
 
This is untested, but try:
Code:
Private Sub Count_Click()
    Dim OpenRecordCheck As Integer
        'Check to see if there are any open incidents
 
        OpenRecordCheck = DCount("[ID]", "[Table1 Query]", "[Tick] = True")
        If OpenRecordCheck > 0 Then
            MsgBox (OpenRecordCheck)
        End If
End Sub
 
Many thanks, spot on.
 
BTW. You could give a more meaningful message with:
MsgBox "Incident count is: " & OpenRecordCheck
 
BTW. You could give a more meaningful message with:
MsgBox "Incident count is: " & OpenRecordCheck

Yeah, thanks, I realsie that but this is just the first piece of something Im improving on, the message box wont matter in the end. But thanks afor the help anyways
 

Users who are viewing this thread

Back
Top Bottom