"wrldruler" <fi******@hotmail.comwrote
First, I know it's against "Access Law" to
save calculations in a table, but....I want/need to.
You need to learn to be more precise. What you stated first is not so...
what is so is that you should not store in a Field in a Record a value that
can be calculated when needed from other Fields in the same Record. What you
stated second is only partly true: you may want to store the largest value
of three Fields in another Field in the same Record, but you definitely do
not _NEED_ to.
I currently have sub-totals being calculated inside
a form, using DMax, DCount, and DSum. But these
aggregate functions are slowing down the interface
and annoying me. So I have decided not to show sub-
totals on the form.
You may be using DMax, DCount, and DSum in calculations. If you think they
are working on values within the same Record, as is clear you expect for
DMax in a later statement here, then you are in for some surprises. DMax is
not the same as the MAX function from Excel, and DSum is not the same as the
SUM function from Excel. Why you would use a Count function on Fields that
you specify within the same record, I couldn't guess, so perhaps your later
statement is the one that's misleading.
But I still need the sub-total calculations performed
so the sub-total data can be used on other forms, reports,
exports, etc.
I was thinking about doing a mass-update via query
when the user finishes an entry. So rather than having
a pause everytime he enters a number, I would just
wait until the end, and mass-update.
But as you know, you can't create an Update query
using an aggregate funciton.
Yes, you can. It rarely makes any sense to do so, unless you are calculating
a percentage of the sum of all Fields in the database when the current Field
value is entered, or similar...
So say I have:
Record # 123:
Table Field A: 10
Table Field B: 5
Table Field C: 20
I want Table Field D to be Dmax(A, B, C).
In this case I would want 20 stored in this field.
Is there any way I can run an update query, pull
out the DMax of that record, and store it in a
field of the same record?
You can certainly use DMax in the Update To line of an Update Query, but it
certainly will not do what you clearly expect (which would be to act like
the MAX function in Excel).
I don't know what you expect from "DMax(A,B,C)" but if it is the maximum of
the three values A, B, and C in that record, you are going to be sadly
disappointed, and you really need to open a Module window, type in ' DMax,
then put the cursor on DMax, press F1 and read the Help. DMax returns the
largest value in the same Field from a domain specified in the statement.
And, almost certainly, if you have three values for the same "sort of thing"
as fields in your Table, and want to store the largest of these back in the
same Table, what you need to be doing is _not_ figuring out how to do that,
but taking a look at how you need to re-design your data and table layout.
But, if you feel compelled to start with a poor design, not realize you are
"in trouble and need to stop digging," and continue doing things that are
going to make your life miserable and more difficult as you continue, the
following will return the largest value of the three fields:
IIf(C (IIf(B A, B, A)), C, IIf(B A, B, A))
You should be able to use that in the Update To line of an Update Query to
set the D field. But, I warn you, you'll be sorrrrreeeeeeey.
Looks like you want to "commit spreadsheet" in your Access database, and
that's guaranteed to be a "losing proposition."
Larry Linson