M
Mike
Hello,
I am attempting to run a query that totals a field in the
table as the query executes, then stops selecting records
once that total is reached. Therefore, the query is not a
SUM, but more a calculation.
There is a single field that has a currency amount in the
table, cAmount.
I wish the user to enter a parameter variable of
varTotalCandyBudget.
Then I wish to print as many records as I can until the
varTotalCandyBudget is reach (or exhausted).
An analogy would be a table containing candy. In the
candy table is a field cAmount, which represents how much
a piece of candy costs.
A child has a five dollar bill. He is only interested in
how many pieces of different candy he can get with his
five dollars. Our program would prompt the user for "How
much money do you have to buy candy with?"
The output would represent a number of records in which
the cAmount field, totaled of all records in the record
set, was less than five dollars. So say each piece of
candle was less than fifty cents. Our query would print
the first x records in the table until the five dollars
was spent. This is calculated by subtracting each piece
of candle, or record cAmount, from the five dollars. I
also have the cAmount set to ascending order in the query
to ensure the user can get the most candy for his 5
dollars starting with the less expensive candy first.
The pseudo code is something like
Select tblCandy!candyName
From tblCandy
Where tblCandy!cAmount < varTotalCandyBudget -=
(varTotalCandyBudget - tblCandy!cAmount)
Can I do this in Access? Basically, the
varTotalCandyBudget amount would be subtracted the amount
of cAmount when on each record until the amount hits zero,
or is less than any of the remaining candies.
I'm new at Access and am not sure if I am doing this
correctly. But I am sure about the need to enter an
amount, and print the rows that fall under the
accumulative amount of the number entered.
Thanks in advance for your time, as I am totally stuck!
Mike
I am attempting to run a query that totals a field in the
table as the query executes, then stops selecting records
once that total is reached. Therefore, the query is not a
SUM, but more a calculation.
There is a single field that has a currency amount in the
table, cAmount.
I wish the user to enter a parameter variable of
varTotalCandyBudget.
Then I wish to print as many records as I can until the
varTotalCandyBudget is reach (or exhausted).
An analogy would be a table containing candy. In the
candy table is a field cAmount, which represents how much
a piece of candy costs.
A child has a five dollar bill. He is only interested in
how many pieces of different candy he can get with his
five dollars. Our program would prompt the user for "How
much money do you have to buy candy with?"
The output would represent a number of records in which
the cAmount field, totaled of all records in the record
set, was less than five dollars. So say each piece of
candle was less than fifty cents. Our query would print
the first x records in the table until the five dollars
was spent. This is calculated by subtracting each piece
of candle, or record cAmount, from the five dollars. I
also have the cAmount set to ascending order in the query
to ensure the user can get the most candy for his 5
dollars starting with the less expensive candy first.
The pseudo code is something like
Select tblCandy!candyName
From tblCandy
Where tblCandy!cAmount < varTotalCandyBudget -=
(varTotalCandyBudget - tblCandy!cAmount)
Can I do this in Access? Basically, the
varTotalCandyBudget amount would be subtracted the amount
of cAmount when on each record until the amount hits zero,
or is less than any of the remaining candies.
I'm new at Access and am not sure if I am doing this
correctly. But I am sure about the need to enter an
amount, and print the rows that fall under the
accumulative amount of the number entered.
Thanks in advance for your time, as I am totally stuck!
Mike