Hi:
I've been tearing my hair out over this one for a few days; did a search
of the archives and found similar questions but no real answers. Here goes:
This is an application for a retail store. There are transactions,
transaction details, and then, depending on the type of detail, related
records in other tables. So when I'm entering a new transaction, I open
a new form (dialog mode) in which additional detail is entered. I need
to bring the total fee for that detail back to the main form. Please
don't tell me to use subforms; they don't work for this application.
Here's the problem:
The form I call [repair dialog] has a calculated control called
totalamt, which holds the total of the the various parts of the repair
(might be several sub-records for each type of repair). This total
needs to go back to the main form (transactions), in two places:
transAmt (amount for this transaction) and finalAmt (which is only
entered if the transaction is to be completed--they price some
transactions that the customer might not accept).
When I'm closing the repair dialog, I have the following code in the
on_close event:
[Forms]![Transactions]![transDetailSub].[Form]![transAmt] =
Forms![repair dialog]!totalamt
If Forms!Transactions!transDetailSub.Form!transType <>
"suggested repair" Then
[Forms]![Transactions]![transDetailSub].[Form]![finalAmt] =
Forms![repair dialog]!totalamt
End If
When I just close the repair dialog, this code does not run properly; it
transfers $0 to the main transaction form, instead of the correct
calculated amount. However, if I step through the code to see where
it's failing, it works just fine. If I put the break at the If
statement, then the second part works fine but the first part still
returns $0.
Here's what I've tried:
copying the total to a global variable first
running the code in another part of the process (every time a line is
updated, for example--way too heavy on resources and it fails anyway)
sticking in some DoEvents (but since I'm not really solid on how they
work, I may be doing that wrong)
inserting the calculation (the source for totalamt) instead of the
field totalamt
The search I did suggested that calculated controls are a low priority
for Access so it does them last, after other actions. But I don't know
how to address this problem (that's what the doEvents were supposed to
do, I guess).
Ideas?
Thanks.
Jan