I have problems with the wording of the criteria of a DCount
function.
On click()
I would like to have the number of occurrences of the field "YearMonth" in a tale in accordance with the value entered in an inbound fields called "Txt_entry".
My code ignores the criteria given (and returns 0) given that its wording is wrong but I cannot find out what would be the correct wording.
Private Sub Ctl3_Click()
Dim db As Database
Dim r As Recordset
Dim YearMonth As Field
Dim Txt_entry As String
Set db = CurrentDb()
Set r = db.OpenRecordset("Table")
Set YearMonth = r.Fields("YearMonth")
MsgBox (DCount("YearMonth", "Table", "[YearMonth]=" & Me.Txt_entry))
End Sub
Thanks!
YearMonth = 201510
– Fionnuala