Solved DCount

hhag

Member
Local time
Today, 01:08
Joined
Mar 23, 2020
Messages
69
Hi,
I try to summarize the number of records with a specific field value.
I use the follwing vba code:
me.txtNumberOf=DCount("StatusID","tblOffer","StatusID=1")

I get error code 438; The object doesn't support the property or method.
The anoying thing is that I've other similar DCount expressions in the same module that works. The difference I see is that I don't set any criterie in these expressens that are the same as my expression above ("StatusID"). This might be the point? Is it possible to have 'expression' the same as 'Criteria'?

Grateful for some advice, thanks.
 
use asterisk:
=DCount("*","tblOffer","StatusID=1")

IF statusID is numeric.
if that field is a string , use delimiters:
=DCount("*","tblOffer","StatusID='1'")
 
Also make sure that's a textbox, not a label. If it's a label, you'd have to set its caption property.
 
Thanks, good idea, but I still gives error... :-(
 
I need to leave my PC for a couple of hours..
 
Your original code was fine. The error relates to setting the default property of txtNumberOf.
What kind of control is txtNumberOf ?
 
Hi, really strange. I thought my first code was fine. And it was a textbox as well. I erased the textbox and created a new one. And then all of a sudden it worked.
Thanks all for your quick support! I appreciate it! 🙏 :)
 
Glad you got it sorted.
 

Users who are viewing this thread

Back
Top Bottom