473,386 Members | 1,842 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.

Test for common values

Hi all,
I've looked through the archives and I haven't been able to find or at
least recognize the solution to my problem. I have a student data
base, Access 2000.

I have 12 school districts. Each school district has from 1-5 schools.
Each school provides some special education services, but not
necessarily all of the services that are provided within the county. I
need to create a report that does this:

SchoolDistA has 3 schools
School 1 provides services 20, 26, 50 (codes)
School 2 provides services 20, 57, 58
School 3 provides services 20, 42, 57

If a service is provided at each of the schools within a single
district, I need to be able to list that in the School District group
header, but not in the detail. If a service is provided at only some
of the schools, I need for it to remain in the detail for that school.
I would greatly appreciate some suggestions on how to approach this.
Thanks,
Nancy

Nov 13 '05 #1
2 1368
Wyllielass wrote:
I would greatly appreciate some suggestions on how to approach this.
Thanks,
Nancy


I used the following test table:

tblSchoolServices:
SServID AutoNumber Primary Key
DistrictID Long Foreign Key
SchoolID Long Foreign Key
ServiceID Long Foreign Key

1 1 1 20
2 1 1 26
3 1 1 50
4 1 2 20
5 1 2 57
6 1 2 58
7 1 3 20
8 1 3 42
9 1 3 57
10 2 4 20
11 2 4 50

Show the DistrictID (invisibly?) along with the DistrictName in the
ReportHeader

School District Group Header
txtDistrictID
txtDistrictName
lstServicesAvailableInAllSchoolsInDistrict.Visible =
SomeBooleanFunctionOf(DistrictID)?

tblSchoolServices_Crosstab:
TRANSFORM Count(tblSchoolServices.SchoolID) AS CountOfSchoolID SELECT
tblSchoolServices.ServiceID, Count(tblSchoolServices.SchoolID) AS
SchoolsWithService FROM tblSchoolServices WHERE DistrictID = " &
txtDistrictID.Value & " GROUP BY tblSchoolServices.DistrictID,
tblSchoolServices.ServiceID PIVOT tblSchoolServices.SchoolID;

Gives for DistrictID = 1 (inserted manually):
ServiceID SchoolsWithService 1 2 3
20 3 1 1 1
26 1 1
42 1 1
50 1 1
57 2 1 1
58 1 1

Any of the SchoolsWithService numbers that match the number of schools
in the district will need to be displayed in the header. The others,
if any, must go in the Detail section.

qryEnumerateSchoolsByDistrict:
SELECT DISTINCT DistrictID, SchoolID FROM tblSchoolServices GROUP BY
DistrictID, SchoolID;

Gives:
DistrictID SchoolID
1 1
1 2
1 3
2 4

strSQL for qrySchoolsInDistrict:
"SELECT DistrictID, Count(SchoolID) AS SchoolsInDistrict FROM
qryEnumerateSchoolsByDistrict WHERE DistrictID = " &
txtDistrictID.Value & " GROUP BY DistrictID;"

Gives for DistrictID = 1 (inserted manually):
DistrictID SchoolsInDistrict
1 3

strSQL for qryServiceIDsToShowInGroupHeader:
"SELECT DISTINCT tblSchoolServices_Crosstab.ServiceID FROM
tblSchoolServices_Crosstab INNER JOIN qrySchoolsInDistrict ON
tblSchoolServices_Crosstab.SchoolsWithService =
qrySchoolsInDistrict.SchoolsInDistrict WHERE
qrySchoolsInDistrict.DistrictID=" & txtDistrictID.Value & ";"

Gives for DistrictID = 1 (inserted manually):
ServiceID
20

strSQL for qryServiceIDsToShowInDetailSection:
"SELECT DISTINCT tblSchoolServices_Crosstab.ServiceID FROM
tblSchoolServices_Crosstab INNER JOIN qrySchoolsInDistrict ON
tblSchoolServices_Crosstab.SchoolsWithService <>
qrySchoolsInDistrict.SchoolsInDistrict WHERE
qrySchoolsInDistrict.DistrictID=" & txtDistrictID.Value & ";"

Gives for DistrictID = 1 (inserted manually):
ServiceID
26
42
50
57
58

Perhaps the RecordCount of these queries can be used to set the Visible
Property of a Listbox in the Group Header and of a Listbox in the
Detail Section. I dunno. Hopefully these queries will give you a
start in tackling this difficult problem. I'm not sure how this
technique will pan out when used in report code. Tables, Queries and
Listboxes can use shorter, less descriptive names. Disclaimer: I'm not
that great with crosstab queries yet so be sure to test the results
thoroughly. Hopefully someone will have a better approach. No
warranties are implied, use at your own risk, not responsible for lost
time, productivity, effectiveness, etc.

James A. Fortune

Nov 13 '05 #2
I haven't had time to work on this but I did want to thank you for
taking the time to think about it and offer a solution. I learn quite
a lot from this group.

Nov 13 '05 #3

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

Similar topics

41
by: Roy Smith | last post by:
I've used the standard unittest (pyunit) module on a few projects in the past and have always thought it basicly worked fine but was just a little too complicated for what it did. I'm starting a...
26
by: Ney Andr de Mello Zunino | last post by:
Hello. I have noticed, in a lot of C and C++ code, that many programmers seem to prefer putting the test values first in conditional expressions. I.e., they would rather write this: if (-1 ==...
6
by: trentdk | last post by:
I want to test which language (testing C and FORTRAN) would be faster with math calculations; one test with intergers, and another test with floats. What math formulas/functions would you guys use...
6
by: Ben Finney | last post by:
Howdy all, Summary: I'm looking for idioms in unit tests for factoring out repetitive iteration over test data. I explain my current practice, and why it's unsatisfactory. When following...
5
by: Little | last post by:
I have this program and I need to work on the test portion, which tests if a Val is in the list. It returns false no matter what could you look at the part and see what might need to be done to fix...
2
by: Netkiller | last post by:
#!/usr/bin/python # -*- coding: utf-8 -*- """ Project: Network News Transport Protocol Server Program Description: 基于数据库的新闻组,实现BBS前端使用NNTP协议来访问贴子...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
6
by: Peter | last post by:
Hi I have a number of arrays of longs, from which I need to find a single array which only contains the values which appear in all the original arrays. For example, I could have the three...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
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: 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: 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...
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
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.