access vba - DCount function wording of the CRITERIA -
i have problems wording of criteria of dcount
function.
on click()
have number of occurrences of field "yearmonth" in tale in accordance value entered in inbound fields called "txt_entry".
my code ignores criteria given (and returns 0) given wording wrong cannot find out correct wording.
private sub ctl3_click() dim db database dim r recordset dim yearmonth field dim txt_entry 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!
you can try:
for string dcount("yearmonth", "table", "[yearmonth]= '" & me.txt_entry & "'")
for date: dcount("yearmonth", "table", "[yearmonth]= #" & me.txt_entry & "#")
depending how store in database. dont need set variables dcount or dlookup(assuming want count)
variables need set if have other criteria want enter in clause of dcount.
as me.text_entry , try me.text_entry.value , see if box has actual value.
you can test throwing msgbox(me.txt_entry.value) may cause of not getting proper count. query end yearmonth = "" without proper value.
Comments
Post a Comment