473,395 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

count query

I have some code that counts the number of times that 0 (zero) is entered in a table. I want to save this to a variable and print it out in a msgbox. What I get as the variable is a repeat of the select statement. what am I doing wrong? Here is my code

Dim Zeros As Integer

Zeros = "SELECT Count(MarketDataTemp.ACPS) AS CountOfACPS" & _
"FROM MarketDataTemp" & _
"WHERE (((MarketDataTemp.ACPS)=0));"
Debug.Print Zeros
MsgAnswer = MsgBox("There are " & Zeros & "prices equal to '0' in the MarketData file", vbYesNo)
If MsgAnswer = 7 Then
Exit Sub
End If
Sep 14 '06 #1
2 1730
ADezii
8,834 Expert 8TB
I have some code that counts the number of times that 0 (zero) is entered in a table. I want to save this to a variable and print it out in a msgbox. What I get as the variable is a repeat of the select statement. what am I doing wrong? Here is my code

Dim Zeros As Integer

Zeros = "SELECT Count(MarketDataTemp.ACPS) AS CountOfACPS" & _
"FROM MarketDataTemp" & _
"WHERE (((MarketDataTemp.ACPS)=0));"
Debug.Print Zeros
MsgAnswer = MsgBox("There are " & Zeros & "prices equal to '0' in the MarketData file", vbYesNo)
If MsgAnswer = 7 Then
Exit Sub
End If

Dim intNoOfZeros As Integer
intNoOfZeros = DCount("*", "MarketDataTemp", "[MarketDataTemp].[ACPS]=0")
'The rest is easy enough
Sep 15 '06 #2
Dim intNoOfZeros As Integer
intNoOfZeros = DCount("*", "MarketDataTemp", "[MarketDataTemp].[ACPS]=0")
'The rest is easy enough
It worked like a charm...thank you much!!
Sep 15 '06 #3

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

Similar topics

4
by: leegold2 | last post by:
Below is some code from a FULLTEXT search. My question is how do I get a count of the number of rows found by the search? $query="SELECT * FROM balloon_txt WHERE MATCH(access_no, recs_txt)...
5
by: Terri | last post by:
I have a form with a multi-select combo. I dynamically build a SELECT statement, open a report, and set the recordsource to my dynamic SELECT statement. I count the records returned in the report...
7
by: Hugo L. | last post by:
Dear I have a table with a Text field named "Attest". In that field I can fill in 4 possibilities: A, B, C or D. In a report based om that table I want to count how many times I filled in...
6
by: Nicolae Fieraru | last post by:
Hi All, I have a query, Select Count(BoolField) from tblMyTable, Where BoolField = true. If I run the query by itself, it returns the number of true records I want to use the result of that...
1
by: sunilkeswani | last post by:
Hi I am still new to access. I want to know how i can build a query which can display results from 4 different columns/fields Like. Field1 Field2 Field3 Field4 1 2 1 ...
1
by: heckstein | last post by:
I am working in Access 2002 and trying to create a report from our company's learming management system. I am not a DBA and most of my SQL knowledge has been self taught through trial and error. I...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
3
by: Auddog | last post by:
I have the following query that works in mysql: select id, order_no, price, count(item_no), sum(price) from production WHERE item_no = '27714' group by item_no; When I setup my query in php,...
5
by: Genalube | last post by:
I am trying to count the number of owners that show up in a query (conveyQuery). The query will produce a column OwnName that will contain names like John Smith, Mike Jones, Frank Vaugn. Each of...
1
by: kummu4help | last post by:
hi, i am using mysql. i have 3 tables with following structures. these are not actual tables i am working on. table A id varchar(16),name varchar(255),InDate datetime table B id...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.