By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,390 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,390 IT Pros & Developers. It's quick & easy.

How to use SQL queries in a report????

P: n/a
Hello:

Thanks for reading this.

I would like to build a report (Access 2002) that uses SQL queries to
count records in specific groups.

I've tried several methods and so far no luck.

Could someone please point me in the right direction on this one. It
dosen't have to be SQL queries, but I could not find another way to do
this with Access functions in any of my books or on the Access web site
or knowledge base site.

Thanks for any guidance.

Richard Hollingsworth

Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Have you investigated the sorting and grouping feature in reports
themselves? (In report design view, select Sorting and Grouping from the
View menu to display the Sorting and Grouping dialog box).

Using the Count() function in a group footer section, for example, would
give you a count of only the records in that group.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...
Hello:

Thanks for reading this.

I would like to build a report (Access 2002) that uses SQL queries to
count records in specific groups.

I've tried several methods and so far no luck.

Could someone please point me in the right direction on this one. It
dosen't have to be SQL queries, but I could not find another way to do
this with Access functions in any of my books or on the Access web site
or knowledge base site.

Thanks for any guidance.

Richard Hollingsworth

Nov 12 '05 #2

P: n/a
OK, nice idea but.......

From what I've tried, you can only group records once using the GUI.
Fine, so I do that for the first group of records and use count() to
tally the results for that group.

Now, I need to do the same thing for 3 other groups (group bys). So,
how do I do that on a report?

Richard

Brendan Reynolds wrote:
Have you investigated the sorting and grouping feature in reports
themselves? (In report design view, select Sorting and Grouping from the
View menu to display the Sorting and Grouping dialog box).

Using the Count() function in a group footer section, for example, would
give you a count of only the records in that group.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...

Hello:

Thanks for reading this.

I would like to build a report (Access 2002) that uses SQL queries to
count records in specific groups.

I've tried several methods and so far no luck.

Could someone please point me in the right direction on this one. It
dosen't have to be SQL queries, but I could not find another way to do
this with Access functions in any of my books or on the Access web site
or knowledge base site.

Thanks for any guidance.

Richard Hollingsworth



Nov 12 '05 #3

P: n/a
I'm not sure that I understand what you mean by 'you can only group records
once using the GUI', Richard. You can define up to 10 grouping levels, and
the group header and group footer sections will be repeated for each
occurrence of that group.

It's also possible that the best solution to your problem might be a summary
query, or even subreports. I really don't have enough information to go on -
for example, what is it in your data that defines a group?

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...
OK, nice idea but.......

From what I've tried, you can only group records once using the GUI.
Fine, so I do that for the first group of records and use count() to
tally the results for that group.

Now, I need to do the same thing for 3 other groups (group bys). So,
how do I do that on a report?

Richard

Brendan Reynolds wrote:
Have you investigated the sorting and grouping feature in reports
themselves? (In report design view, select Sorting and Grouping from the
View menu to display the Sorting and Grouping dialog box).

Using the Count() function in a group footer section, for example, would
give you a count of only the records in that group.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...

Hello:

Thanks for reading this.

I would like to build a report (Access 2002) that uses SQL queries to
count records in specific groups.

I've tried several methods and so far no luck.

Could someone please point me in the right direction on this one. It
dosen't have to be SQL queries, but I could not find another way to do
this with Access functions in any of my books or on the Access web site
or knowledge base site.

Thanks for any guidance.

Richard Hollingsworth


Nov 12 '05 #4

P: n/a
Ok, here's the scoop.......

Lets say I have a few thousand records, say 5 thousand.

These 5K records consist of, say, 12 individual fields.

3 of those fields are...
1) stdverifyby varchar 15
2) RA varchar 4
3) RFR varchar 6

Ok, these are all text fields, not numbers.

Now, boss wants a report generating statistics on these 3 fields.

Report should look something like this.....
Verification Method:

Demonstration: 3245
Test 1345
Inspection 1245
Analysis 75
Test Case Assignments:

Richard 188
John 144
Robert 55
Jeff 200
Janet 66

Runs For Record Completions:

Failed 335
Verified 3578
Not Verified 2589

Ok, I think you get the jest.......
Now, my initial thought was to create an empty report and create 12
individual text boxes, then tie a SQL statement to each box to get the
numbers. For example.......

In the "Record Source" property of the
box......=Select count(node) from BL321RTM where stdverifyby = "test"

Well, I've tried several versions of that and nothing will compile.

Sum() and Dcount() won't work here because these fields are not numeric,
so the SQL approach is the only way I know to do this.

PS: I've also tried creating a VBA procedure with the SQL statements
in a Form Load event. That did'n't seem to work either.

So, any ideas???????
Much thanks for your time on this one.......

Richard H
Brendan Reynolds wrote:
I'm not sure that I understand what you mean by 'you can only group records
once using the GUI', Richard. You can define up to 10 grouping levels, and
the group header and group footer sections will be repeated for each
occurrence of that group.

It's also possible that the best solution to your problem might be a summary
query, or even subreports. I really don't have enough information to go on -
for example, what is it in your data that defines a group?

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...

OK, nice idea but.......

From what I've tried, you can only group records once using the GUI.
Fine, so I do that for the first group of records and use count() to
tally the results for that group.

Now, I need to do the same thing for 3 other groups (group bys). So,
how do I do that on a report?

Richard

Brendan Reynolds wrote:
Have you investigated the sorting and grouping feature in reports
themselves? (In report design view, select Sorting and Grouping from the
View menu to display the Sorting and Grouping dialog box).

Using the Count() function in a group footer section, for example, would
give you a count of only the records in that group.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...


Hello:

Thanks for reading this.

I would like to build a report (Access 2002) that uses SQL queries to
count records in specific groups.

I've tried several methods and so far no luck.

Could someone please point me in the right direction on this one. It
dosen't have to be SQL queries, but I could not find another way to do
this with Access functions in any of my books or on the Access web site
or knowledge base site.

Thanks for any guidance.

Richard Hollingsworth





Nov 12 '05 #5

P: n/a
Richard Holliingsworth <wi*********************@boeing.com> wrote in message news:<Hs********@news.boeing.com>...
In the "Record Source" property of the
box......=Select count(node) from BL321RTM where stdverifyby = "test"

Well, I've tried several versions of that and nothing will compile.


Richard,
have you tried:

=dcount("stdVerifyBy","tblYourTable","stdVerifyBy= 'Test'")

in the controlSource for the text box

If you want to give the name and fields of your table and a few
(<5k!) rows of the table (is there really only one table?) we may be
more help.

good luck,
Martin
Nov 12 '05 #6

P: n/a
The following union query ...

SELECT stdverifyby AS TheGroup, Count(*) AS TheCount, "Verification Method"
AS Heading
FROM tblTest
GROUP BY stdverifyby
UNION SELECT RA, Count(*), "Test Case Assignments"
FROM tblTest
GROUP BY RA
UNION SELECT RFR, Count(*), "Runs for Record Completions"
FROM tblTest
GROUP BY RFR;

.... will give you something like this ...

Analysis 3 Verification Method
Demonstration 3 Verification Method
Failed 4 Runs for Record Completions
Inspection 3 Verification Method
Janet 2 Test Case Assignments
Jeff 2 Test Case Assignments
John 3 Test Case Assignments
Not Verified 4 Runs for Record Completions
Richard 3 Test Case Assignments
Robert 2 Test Case Assignments
Test 3 Verification Method
Verified 4 Runs for Record Completions

You can use that as the record source for your report, and in the report
group by 'Heading'.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...
Ok, here's the scoop.......

Lets say I have a few thousand records, say 5 thousand.

These 5K records consist of, say, 12 individual fields.

3 of those fields are...
1) stdverifyby varchar 15
2) RA varchar 4
3) RFR varchar 6

Ok, these are all text fields, not numbers.

Now, boss wants a report generating statistics on these 3 fields.

Report should look something like this.....
Verification Method:

Demonstration: 3245
Test 1345
Inspection 1245
Analysis 75
Test Case Assignments:

Richard 188
John 144
Robert 55
Jeff 200
Janet 66

Runs For Record Completions:

Failed 335
Verified 3578
Not Verified 2589

Ok, I think you get the jest.......
Now, my initial thought was to create an empty report and create 12
individual text boxes, then tie a SQL statement to each box to get the
numbers. For example.......

In the "Record Source" property of the
box......=Select count(node) from BL321RTM where stdverifyby = "test"

Well, I've tried several versions of that and nothing will compile.

Sum() and Dcount() won't work here because these fields are not numeric,
so the SQL approach is the only way I know to do this.

PS: I've also tried creating a VBA procedure with the SQL statements
in a Form Load event. That did'n't seem to work either.

So, any ideas???????
Much thanks for your time on this one.......

Richard H
Brendan Reynolds wrote:
I'm not sure that I understand what you mean by 'you can only group recordsonce using the GUI', Richard. You can define up to 10 grouping levels, andthe group header and group footer sections will be repeated for each
occurrence of that group.

It's also possible that the best solution to your problem might be a summaryquery, or even subreports. I really don't have enough information to go on -for example, what is it in your data that defines a group?

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...

OK, nice idea but.......

From what I've tried, you can only group records once using the GUI.
Fine, so I do that for the first group of records and use count() to
tally the results for that group.

Now, I need to do the same thing for 3 other groups (group bys). So,
how do I do that on a report?

Richard

Brendan Reynolds wrote:

Have you investigated the sorting and grouping feature in reports
themselves? (In report design view, select Sorting and Grouping from theView menu to display the Sorting and Grouping dialog box).

Using the Count() function in a group footer section, for example, wouldgive you a count of only the records in that group.

--
Brendan Reynolds
"Richard Holliingsworth" <wi*********************@boeing.com> wrote in
message news:Hs********@news.boeing.com...


>Hello:
>
>Thanks for reading this.
>
>I would like to build a report (Access 2002) that uses SQL queries to
>count records in specific groups.
>
>I've tried several methods and so far no luck.
>
>Could someone please point me in the right direction on this one. It
>dosen't have to be SQL queries, but I could not find another way to do
>this with Access functions in any of my books or on the Access web site>or knowledge base site.
>
>Thanks for any guidance.
>
>Richard Hollingsworth
>
>
>
>
>


Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.