473,505 Members | 13,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trouble counting blank records with DCount function

283 Contributor
Hello All,

I am trying to use the DCount Function to count blank records on a table from a form. I want to make it so i can press a button and the function will run and show the total in a text box on a form. I can get it to work with non null or non blank fields but for some reason it just keeps showing me 0 when i try to get it to count blank fields. If the DCount function is not the best approach I appreciate any other alternatives. FYI I prefer to do this with VBA and not a query.

Thanks in advance,

Current code I have been working with
Expand|Select|Wrap|Line Numbers
  1. cntMax = DCount("[Name]","Table1","[Name]='""""' ")
  2. txtBox = cntMax
  3.  
Nov 19 '11 #1
3 12215
ADezii
8,834 Recognized Expert Expert
DCount(expr, domain, [criteria])
The DCount Function doesn't count Records that contain Null Values in the Field referenced by expr unless expr is the asterisk (*) Wildcard Character. the following Syntax will work:
Expand|Select|Wrap|Line Numbers
  1. cntMax = DCount("*", "Table1", "IsNull([Name])")
Nov 19 '11 #2
slenish
283 Contributor
Hi ADezii,

appreciate the quick response on this. I was trying the wild card with the asterisk but i was doing it backward and using it at the end of the expression. Works great now really appreciate the help!

Also I like the new picture for you avatar :D

Take care
Nov 19 '11 #3
NeoPa
32,557 Recognized Expert Moderator MVP
For an actual count of records where [Name] is blank you would need to get the total (Using "*" as ADezii suggests) then subtract those with values (Using "[Name]").
Nov 20 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2959
by: Dan Leeder | last post by:
stroccur = DCount("", "empnotes", " = " & Chr(34) & Me.Rpt_Card_Type & Chr(34) & " And = " & Me.SSN & " And #" & & "# > " & DateSerial(Year(Me.datetime) - 1, Month(Me.datetime),...
1
1830
by: SheldonMopes | last post by:
I'm having difficulty with the DCount function, not getting the results that I want. Field1A and Field2A are fields in TableA matching Field1B and Field2B in TableB Using a calculated...
1
1899
by: Geoff | last post by:
FrmBookings is a subform linked to the form FrmParty. The DCount function checks for previous bookings and it works fine but why do I need such a long-winded syntax ie Forms!.Form!! in the...
4
2203
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that...
2
3540
by: propoflady | last post by:
When I do the following union query - it works but it gives me blank records then my list SELECT , FROM BuyerListName UNION SELECT , FROM Buyers ORDER BY ;
1
3438
by: lalbee | last post by:
I am trying to use the Dcount function but receive a data type mismatch error, can someone help me determine the cause? Count: DCount("","qry-final everhome results"," <'0' ") Thanks!
5
1541
by: neelesh kumar | last post by:
sir, i am struggling with a problem in my code.The code is Dim subcode as Variant,intnoofsubquestions(4) as integer,i as integer subcode = Array("ma","phy","che","ece") 'Msgbox myArray(2)...
36
11361
by: bmyers | last post by:
Good afternoon, I am attempting to count only those records within a report, which is based on a query, where Status is equal to Closed. I have tried multiple variations of DCOUNT but am...
1
1814
iBasho
by: iBasho | last post by:
Hi I am using the DCount function to check and alert users for existing IDs in my database after a new record is entered. ..Private Sub CARDID_AfterUpdate() If DCount("*", "", " = '" & Me. &...
1
1801
by: Manuel Baptista | last post by:
Good afternoon, I am attempting to count those records within a data base that do not match one variable answer in a given field. To put it more clearly, I want to count the companies in a...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.