The value of Me.txtLastMonth is a string, so probably something like
Code:
CountRec = DCount("[pkHistoryPayroll]", "tblHistory", "[F17]='" & Me.txtLastMonth & "'")
I myself prefer to use month numbers like 202503 (a numeric value). In case you need for some reason the text value, like you used, simply add a months table like tblMonths: MonthNo, MonthTxt, and read the matching text from there. Or tblMonths: MonthNo, TxtType, MonthTxt - which allows to have text values of months defined for various text types like formats, or languages, or whatever.