Rabu, 12 Februari 2014

[MS_AccessPros] Query simplifications

 

Experts,

I'm going through a application I wrote a few years back to summarize a variety of election statistics on a single page in an attempt to simplify the queries I used. I see several instances where I've created queries with other queries as the source in attempt to put the data in the proper format for graphing. This all works but is hard to follow, so I'm looking for ways to simplify or combine queries where that makes sense.

One simple example is below, where qryPieData uses DCount on qryPieData2 to pull in a total for the calculation of a percentage for use in a pie chart. Also, both queries pull in cboDay from frmInput. 

So is it possible to do all of this in a single query, or is this the best approach? 

Thanks—and any suggestions will be appreciated! Using Access 2012 here.

-----

qryPieData

SELECT IIf(IsNull([PctORVS]),"Unk",IIf([Registrations]![PctORVS]<0.52,"Dem","Rep")) AS Party, [Num]/[Tot] AS Pct, Count(Votes.RegistrantID) AS Num, DCount("RegistrantID","qryPieData2") AS Tot
FROM Registrations INNER JOIN Votes ON Registrations.ID = Votes.RegistrantID
WHERE (((Votes.DayNum)>=[Forms]![frmInput]![cboDay]))
GROUP BY IIf(IsNull([PctORVS]),"Unk",IIf([Registrations]![PctORVS]<0.52,"Dem","Rep"));

qryPieData2

SELECT Votes.RegistrantID
FROM Registrations INNER JOIN Votes ON Registrations.ID = Votes.RegistrantID
WHERE (((Votes.DayNum)>=[Forms]![frmInput]![cboDay]));

——
James
www.james-mc.com
Words To Live By

__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)
.

__,_._,___

Tidak ada komentar:

Posting Komentar