Re: Please Help with creating (what I call) a Dynamic Query
From: Douglas J. Steele (NOSPAM_djsteele_at_NOSPAM_canada.com)
Date: 03/17/05
- Next message: JaRa: "RE: Output query data to a field in a form"
- Previous message: JaRa: "RE: Summing Counts for sorting?"
- In reply to: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Next in thread: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Reply: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Mar 2005 17:54:51 -0500
I think using a query to normalize the data would help significantly.
Create a query along the lines of the following, and name it (for the sake
of illustration) qryMonthlyBudget:
SELECT AccountNo, 1 AS MonthNumber, Month1 AS MonthValue
FROM MonthlyBudget
UNION
SELECT AccountNo, 2 AS MonthNumber, Month2 AS MonthValue
FROM MonthlyBudget
UNION
SELECT AccountNo, 3 AS MonthNumber, Month3 AS MonthValue
FROM MonthlyBudget
etc.
Now, to get only the results for month 2, you simply need:
SELECT AccountNo, MonthValue
FROM qryMonthlyBudget
WHERE MonthNumber = 2
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "GM" <ghm101@hotmail.com> wrote in message news:enEK7xzKFHA.4052@tk2msftngp13.phx.gbl... > Hi Tom > > Thanks for your answer, I hear, understand and agreee your point re > normalisation, but his data comes from a Sage line 50 database brought to > my Access DB as link tables. > > The table in question stores several separate types of data, representing > the months of the year as follows > BalanceMth1, BalanceMth2...etc....BalanceMth12, BudgetMth1, > BudgetMth2..etc .BudgetMth12, YearPriorMth1, > YearPriorMth2..etc..YearPriorMth12 > > I guess I could write some queries which would reorganise the data in a > "pseudo" normalised system and then query from there but I didn't thing > that would yield a much better solution. > > Hence my attempt to get a query result in one step. > > Ultimately I am just trying to query and report on the data available, > does my original idea make more sense in this context? or am I better > trying something else? > > Regards > > Greg > >
- Next message: JaRa: "RE: Output query data to a field in a form"
- Previous message: JaRa: "RE: Summing Counts for sorting?"
- In reply to: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Next in thread: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Reply: GM: "Re: Please Help with creating (what I call) a Dynamic Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|