Subform requery endless loop?

J

Jerry

I don't know if this is the right group for this - but I have a Customer
Orders form on which is contained info for each customer in the Customers
table. This form also contains a subform for Orders which lists all orders
for the current Customer on the main form, a second subform for Order
Details listing each item associated with each Order in the Orders subform,
and a third subform showing results of a crosstab query that shows available
inventory. In the Current event of the Orders subform I have this;

Sub Form_Current()

Dim ParentDocName As String

On Error Resume Next
ParentDocName = Me.Parent.Name

If Err <> 0 Then
GoTo Form_Current_Exit
Else
On Error GoTo Form_Current_Err
Me.Parent![Order Details Subform].Requery
End If

Form_Current_Exit:
Exit Sub

Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit

End Sub

so that when I click on any of the orders in the Orders subform, the Order
Details subform is updated with the information associated with that order.
This works very well until I try to delete a record in the Orders subform,
at which point it locks up. I've tried deleting everything in the Current
event handler except the line that says

Me.Parent![Order Details Subform].Requery

and that appears to be where the problem is. Any one know why or how to fix
it?

Thanks,

Jerry
 
L

Lynn Trapp

Requerying a form causes the form to pull in the data again, thus, the
Current event fires each time you requery. Thus, if you requery a form on
the Current event it will just keep firing over and over. Try putting your
code in the Before Update event of the form or in some other event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top