Oops, I forgot about international settings. You are right - need to use semi-colons.
It works well on the report
If it works in a report, it should work on a form.
Does this cause an error?
Code:
= DCount ("*"; "tblMaster"; "Rank = 'Dean' ")
Yes, is could be converted to a VBA function. Something like this:
Code:
Public Function CountRanks() As Integer
Dim r As DAO.Recordset
Dim sSQL As String
Dim RC As Integer ' RC = record count
RC = 0
sSQL = "SELECT Rank FROM tblMaster"
sSQL = sSQL & " WHERE Rank = 'Dean' OR Rank = 'colonel' OR Rank = 'provider' OR"
sSQL = sSQL & " Rank = 'pioneer' OR Rank = 'captain' OR Rank = 'first lieutenant' OR Rank = 'lieutenant'"
Set r = CurrentDb.OpenRecordset(sSQL)
If Not (r.BOF And r.EOF) Then
r.MoveLast
RC = r.RecordCount
End If
r.Close
Set r = Nothing
CountRanks = RC
End Function
In the control source of the text box:
=CountRanks()