Connecting Tech Pros Worldwide Help | Site Map

problem disappears when I step through code

  #1  
Old March 10th, 2008, 05:15 PM
Jan
Guest
 
Posts: n/a
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
  #2  
Old March 17th, 2008, 06:15 PM
Mike P
Guest
 
Posts: n/a

re: problem disappears when I step through code


On 10 Mar, 17:06, Jan <j...@dontspamme.comwrote:
Quote:
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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
problems with looping, i suppose John Salerno answers 14 April 5th, 2006 12:05 PM
Exception when VB.net app (using MFC ocx) closes. Simon answers 0 November 22nd, 2005 04:15 AM
Exception when VB.net app (using MFC ocx) closes. Simon answers 0 July 21st, 2005 09:59 AM
final version of PEP-318 "Decorators for functions and methods" Anthony Baxter answers 0 July 18th, 2005 03:53 PM