473,386 Members | 1,819 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,386 software developers and data experts.

Count query

Hey group,

I am trying to do a count of the number of papers in a table. The
table has a PaperID that differentiates each paper , e.g. 004.1. Some
papers are reused. The reused paper is given a new PaperID. The
PaperID includes 3 new numbers appended to the original PaperID, e.g.
664.004.1.

When I do a count, I do not want to count the reused paper. I set up a
count query and had the criteria { Not Like "***.***.*" }. I have also
tried the criteria { Not Like "###.###.#" } ,
{ Like "***.*" } and { Like "###.#" } but neither gives me the correct
count. Please help!!!

Jan 12 '06 #1
6 5034
This will work when your original PaperID is always 5 characters like in 004.1
Put this in the criteria-line of the field PaperID in the query grid:
Len([PaperID]=5

Or maybe something like Len([PaperID] <7 when you have 4, 5 or 6 characters originally...

Arno R

"dBNovice" <lu*****@hotmail.com> schreef in bericht news:11*********************@g14g2000cwa.googlegro ups.com...
Hey group,

I am trying to do a count of the number of papers in a table. The
table has a PaperID that differentiates each paper , e.g. 004.1. Some
papers are reused. The reused paper is given a new PaperID. The
PaperID includes 3 new numbers appended to the original PaperID, e.g.
664.004.1.

When I do a count, I do not want to count the reused paper. I set up a
count query and had the criteria { Not Like "***.***.*" }. I have also
tried the criteria { Not Like "###.###.#" } ,
{ Like "***.*" } and { Like "###.#" } but neither gives me the correct
count. Please help!!!

Jan 12 '06 #2
Red
Wild problem..

let me get this straight.. with some examples...

PaperD
004.1
1.004.1
2.004.1
005.1
1.005.1

The count of the above would only be 2, right?

If so, this is how you could do it...I think...

Send your papeerid to a function to extrapolate only the correct info
(everything to the right of the second period), and have your query
count the unique results of that.

Jan 12 '06 #3
You need to add your field "PaperID" to the query twice. The first will have
"Count" in the total row, the second will have "Where" in the total row and
Like("###.#") in the criteria row. Your query would look for the result of
the count (an integer) to be like ###.#

--
Message posted via http://www.accessmonster.com
Jan 12 '06 #4
dBNovice wrote:
Hey group,

I am trying to do a count of the number of papers in a table. The
table has a PaperID that differentiates each paper , e.g. 004.1. Some
papers are reused. The reused paper is given a new PaperID. The
PaperID includes 3 new numbers appended to the original PaperID, e.g.
664.004.1.

When I do a count, I do not want to count the reused paper. I set up a
count query and had the criteria { Not Like "***.***.*" }. I have also
tried the criteria { Not Like "###.###.#" } ,
{ Like "***.*" } and { Like "###.#" } but neither gives me the correct
count. Please help!!!


Perhaps you could check on the length of the field. Let's say you'd
never have a number greater than 004.9999 unless used. You could then
create a column
Expr1:Len(PaperID)
and in the criteria
< 8
You could also create a function and put it in a code module. This is
for A97. You may be able to use SPLIT() to determine the number of
array elements in higher versions. Ex:
Function OccurCnt(strField As String, strSearchFor As String) as Integer
Dim intPos AS Integer
Dim strHold As String
strHold = strField
Do while True
intPos = Instr(strHold,strSearchFor)
If intPos > 0 then
strField = Mid(strHold,intPos + 1)
OccurCnt = OccurCnt + 1
Else
Exit Do
Endif
Loop
End Function

Now in your query you can create a column like this
Expr1:OccurCnt([PaperID],".")
to search for all occurrences of a period and in the criteria enter
1
since those reused will have more than 1 period.

Jan 12 '06 #5
Thank you, I used the first option and it worked. I will try to use
the second option; I'm new to using VB in Access; so I can use the
practice.

Jan 12 '06 #6
I want to say "Thanks!" to everyone who replied.

Jan 12 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.