By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,469 Members | 2,073 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,469 IT Pros & Developers. It's quick & easy.

problem disappears when I step through code

P: n/a
Jan
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
Mar 10 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 10 Mar, 17:06, Jan <j...@dontspamme.comwrote:
Thanks, but the code fails even when nothing has been changed; if I even
open the dialog and close it again, it overwrites the numbers to $0. So
saving the record appears not to be the issue.

Anyone else have ideas?
Your code suggests that you are using subforms. It appears that the 2
total fields, transAmt and finalAmt, are inside a subform control,
'transDetailSub'.
If this is the case, I would check that the 'Link Child Fields' and
'Link Master Fields' of the subform control are what you expect (See
the Data tab of the subform control's property sheet. Presumably, the
Master should be set to the value of the 'Transaction ID' which is the
primary key of the 'Transactions' table and the Child should be set to
the foreign key 'Transactions ID' in the 'Transactions Details'
table.

Mike P
Mar 17 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.