473,657 Members | 2,450 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 12246
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,568 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
2967
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), Day(Me.datetime))) I'm using the above function to count similar records that have fallen in the last year. Ex: SSN datetime cattype # of records in last year
1
1849
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 control in a subform bound to TableB, Field1B and Field2B are on the form. (Control names are txtField1B and txtField2B)
1
1905
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 conditon part of the Dcount. Private Sub SessionCode_BeforeUpdate(Cancel As Integer)
4
2208
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 contains the other information. it is set 1 to 1 in the relationships. simplify if I can
2
3549
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
3450
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
1546
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) is giving che .up to here no problem the next line is For i= 0 to 3 intnoofsubquestions(i)=Dcount("*","tablename"," = 'subcode(i)' ")
36
11413
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 continuously receiving the "#ERROR" message in the control source box on the report. Below is the expression that I have tried to use and modify numerous times. Don't know if i'm just simply having syntax issues or my formula is just wrong. I did...
1
1821
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. & "'") Then MsgBox "This card ID number already exists in the system. Once you enter the dependent code you will be able to determine if this is a subsequent reinbursement submission from the same member or a new submission from another subscriber on the...
1
1828
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 database that are headquartered in several several countries except one, namely Portugal. What is the Dcount function formula that must be used? Best reagards, Manuel Baptista
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.