Form Requery and Loops

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following code in a form. The problem that I have discovered is
that the requery loops until I press escape.

Can anyone shed any light on what I have not done correctly?

Thanks,

Ray.

Private Sub Form_AfterUpdate()

Forms!frmDEFENDANTSmain!frmPAYMENTSscreen.Form.Requery

If Forms!frmDEFENDANTSmain.RemainingBalance > 4.99 Then
Call BalanceReceiptLtr
Else
Call ReceiptLtr
End If

End Sub
 
Ray said:
I have the following code in a form. The problem that I have discovered is
that the requery loops until I press escape.

Can anyone shed any light on what I have not done correctly?

Private Sub Form_AfterUpdate()

Forms!frmDEFENDANTSmain!frmPAYMENTSscreen.Form.Requery

If Forms!frmDEFENDANTSmain.RemainingBalance > 4.99 Then
Call BalanceReceiptLtr
Else
Call ReceiptLtr
End If

End Sub


A complete stab in the dark here, but check to see if there
is any code in the form's Current event or your
BalanceReceiptLtr procedure that dirties the record (i.r.
sets the value of a bound control).
 
Hello Marshall:

I just went through the code to make sure that wasn't taking place. Let me
give a little more information regarding my setup.

1 Main form with 2 sub forms.
1 form to add payments.

The add payment form on the afterupdate event, requery's the payment subform
of the mainform. By requerying the subform, (to include the most recent
payment), the payment totals are updated on the main form.

As it is now, once a payment is saved, the requery ends up looping and
requires that I hit <ESC> in order to stop it and move forward ...

Thanks,

Ray.
 
There may be some wierd thing that's interfering (e.g.
corruption, another user doingthe same thing, ???), but
that's kind of a cop out. Most likely it is something along
the lines of your code making the subform's data dirty or
its requerying itself.

The part about Esc stopping the requery process is very
suspicious and might be a significant clue. Esc is supposed
to undo the latest unsaved change to the data in the control
with the focus. Esc does not break a code loop like Ctrl+C
does.
 
OK, here's a little bit more information.

If I use the code as follows, the update is correct with no looping.
However, if I remove the REM marks and actively use the IF statements to
print either the receipt or the balancedue letter, THAT is when the (what I
am calling) looping occurs.

Hopefully this will provide some clues...

Thanks,

Ray.

Private Sub Form_AfterUpdate()

Forms!frmDEFENDANTSmain!frmPAYMENTSscreen.Requery


' If Forms!frmDEFENDANTSmain.RemainingBalance > 4.99 Then
' Call BalanceReceiptLtr
' Else
' Call ReceiptLtr
' End If

End Sub


Marshall Barton said:
There may be some wierd thing that's interfering (e.g.
corruption, another user doingthe same thing, ???), but
that's kind of a cop out. Most likely it is something along
the lines of your code making the subform's data dirty or
its requerying itself.

The part about Esc stopping the requery process is very
suspicious and might be a significant clue. Esc is supposed
to undo the latest unsaved change to the data in the control
with the focus. Esc does not break a code loop like Ctrl+C
does.
--
Marsh
MVP [MS Access]


Ray said:
I just went through the code to make sure that wasn't taking place. Let me
give a little more information regarding my setup.

1 Main form with 2 sub forms.
1 form to add payments.

The add payment form on the afterupdate event, requery's the payment subform
of the mainform. By requerying the subform, (to include the most recent
payment), the payment totals are updated on the main form.

As it is now, once a payment is saved, the requery ends up looping and
requires that I hit <ESC> in order to stop it and move forward ...
 
It seems the requery is not the problem.

Have you tried placing a break point on the If and single
stepping from there to see what code is actually executing?
 
Back
Top