Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup using null criteria 2

Status
Not open for further replies.

ftook

Programmer
Dec 4, 2006
80
0
0
GB
Im trying to count how many records have a null entry in field [credit], ive tried :

Me.var1 = DCount("[Pono]", "PO Returns", "[credit] = ''"))

[credit] is a text field

doesnt seem to count correctly - can anyone help please ?
 
[credit] = '' will count records where the field is empty, not null (there is a difference).

You'll need to use

Code:
Me.var1 = DCount("[Pono]", "PO Returns", "[credit] Is Null"))

Ed Metcalfe

Please do not feed the trolls.....
 
Thank you Ed - worked great ***
 
You're welcome.

BTW - The difference between the two can be regarded as:

Null - Value is unknown.
Empty ("") - No value for this record.

Sometimes you will want to count one or the other value, sometimes you will want to count both.

Ed Metcalfe.

Please do not feed the trolls.....
 
ive extended the function, and it now gives type mismatch

If DCount("[Pono]", "PO Returns", "[credit] Is Null" And "[pono] = " & Me.pno) = 0

pono is integer

where am i going wrong
 
This where criteria needs to be a string so:

"[credit] Is Null And [pono] = " & Me.pno

with AND outstide the parentheses it looks to vba as a variable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top