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 dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count NULL records

Status
Not open for further replies.

davidmcolaco

Technical User
Aug 1, 2005
102
PT
Hi,

I have a form where I display some stats from what zone in country are the customers from, but I want to count the records where I don't have information too, that are empty.
How can I do that? I was trying this code, but it doesn't work.

ClientesRS.Open "SELECT * From Clientes WHERE c_distrito=''", m_oConn
txtSemDistrito.Text = ClientesRS.RecordCount

Thanks in advance.
 
NULLs are not the same as empty strings. Luckily, you can convert nulls to empty strings for comparisons.

Also, you don't need to return a full recordset, you can use the database to perform a count.

Select Count(*) As Count
From Clientes
Where IsNull(c_distrito, '') = ''

Then
txtSemDistrito.Text = RS("Count")



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
And you don't even need to replace the nulls if you aren't doing anything with them anyway. You could also just make the where clause:

Where c_distrito IS NULL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top