Label not showing on subform if value is 0 (1 Viewer)

and try using "*" rather than "1" in the dcount function
Actually I have read this long time on one of my Access books.
I am too lazy to look through all my numerous books, so I
asked AI.

Here is what AI has to say:

Question:
Can i use "1" instead of "*" in Dcount domain function in ms access?

Answer:
Yes, you can use "1" instead of "*" in DCount, and it's actually more efficient!

Both work the same way:

vba
' These are equivalent:
DCount("*", "Customers")
DCount("1", "Customers")

' With criteria:
DCount("*", "Orders", "Status='Active'")
DCount("1", "Orders", "Status='Active'")
Why "1" is better:

Faster - Access doesn't need to resolve field names
No field name conflicts - Won't break if you rename/delete fields
Clearer intent - You're just counting records, not referencing actual data
Performance comparison:

vba
' Slower - Access must validate field exists
DCount("*", "LargeTable", "Status='Active'")

' Faster - Just counts records
DCount("1", "LargeTable", "Status='Active'")

' Also works with specific field (counts non-null values)
DCount("CustomerID", "Orders") ' Only counts non-NULL CustomerIDs
Best practices:

Use "1" when counting all records
Use "FieldName" when you want to count only non-NULL values in that field
Use "*" if you prefer traditional SQL syntax
Example:

vba
' Count all customers
Debug.Print DCount("1", "Customers") ' ✅ Recommended

' Count customers with email
Debug.Print DCount("Email", "Customers") ' Counts non-NULL emails

' Count active orders
Debug.Print DCount("1", "Orders", "Status='Active'") ' ✅ Best performance
So yes, use "1" - it's a better choice! 🚀
 
Last edited:
can't say I agree with all those comments

Why "1" is better:

Faster - Access doesn't need to resolve field names
No field name conflicts - Won't break if you rename/delete fields
Clearer intent - You're just counting records, not referencing actual data
Performance comparison:

you don't do any of those things using "*" either

comparisons using a field name, ditto

I didn't say don't use 1, just suggested trying * instead. So no need to get defensive. I would point out you can name a field 1 (or *) so that could confuse the issue
 

Users who are viewing this thread

Back
Top Bottom