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

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -