Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access crashes when an on_current event activates on a deleted record

Status
Not open for further replies.

jamesu

Technical User
Sep 27, 2001
7
ZA
Hi there

Have searched the posts and FAQs, but not found anything, so if anyone can give me a hand, or refer me to a relevant post, I would greatly appreciate it.

Here is the problem. I have two subforms on a form. The second one is requeried using the on_current event of the first one:

Code:
Private Sub Form_Current()

[Forms]![Form1]![Subform1].Requery

End Sub

This works well. However, when I delete a record in the first subform, microsoft access stops responding, and I eventually have to shut it down using the task manager.

Dos anyone know how to solve this problem?

Thanks!

James
 
Hi,

Never seen this before, but Access is possibly the buggiest Microsoft product ever! as a quick suggestion have you tried trapping the error, i.e

Code:
private sub form_current()

    on error goto no_record
    [Forms]![Form1]![Subform1].Requery

    exit sub
no_record
    msgbox "No record!"
end sub

Hope this helps

Andrew
 
Hi Andrew

Thanks for the tip. Actually had already tried that, and didn't work. Perhaps I can define the problem better: both the subforms are based on the same table. The first is a datasheet view with a list of the records and with the capacity to add and delete records. The second is in normal form view and allows for more info about each record to be added. The idea is that a person can use one parameter to add or delete records in the first subform, and then add all the details on the second subform. So, I need to update the second subform every time the first one changes. The way I have set it up is to base the source of the second form on a query which is defined by the current record of the first i.e. [Forms]![Horses]![FeedItems subform].[Form]![FeedItemID], and this query is requeried with the on_current event. What I have discovered is that the problem seems to lie with this query. If I remove the criteria mentioned above, it does not crash, but there is no tying together of the two subforms.

So, I hope that makes some sense :) I would really appreciate it if you could make any suggestions, or if you have a better way of solving the problem!

Cheers, and thanks again for your help.

James
 
Hi again

I solved the above problem by creating only one subform, and then having the info from the second one in the footer of the first, and displaying the first as a continuous form. Didn't look quite as good, but worked well.

Thanks for replying Andrew!

Cheers
James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top