Question Access07 "On Exit" error...pls help

70runner

New member
Local time
Today, 09:57
Joined
Mar 20, 2012
Messages
5
Newbie...and trying hard to learn. I basically adapted a general inventory management database in Access 03 to track costs of restoring a classic car. It worked fine until opening it in Access 07. It uses the standard Switchboard app to initiate, from there either add or edit transactions using a form. The db will open fine to the Switchboard layout. If I select edit a form, the form will open normally to the first record in the db. However, if I either advance the form to the next record or close it (or even switch to design view), I get the following error msg: "The expression On Exit you entered as the event property setting produced the following error: The object doesn't contain the Automation object 'AfterInsert'. Google led me to a possible cause, an apparent issue with 07 where it doesn't particularly like tables & forms with the same name. I had that condition, fixed it, but still get the error. To be honest I don't really understand the error msg as I can find no "On Exit" or "AfterInsert" statement in the form properties. Any suggestions much appreciated.
 
Hi 70Runner,

Most likely, it is referring to a form event. Check the Form's property list and if you see any events with "[Event Procedure]" next to them, then check the respective vb code on the form. In your case, look for an event called AfterInsert. Play around with the debugging options of setting breakpoints and stepping through the code to pinpoint exactly where the error is being raised.

Once you find the offending code, you can research a bit more. If you're still stuck, you can always paste the code here, or if you're REALLY stuck, you can post the entire db.
 
Thx Ross. The form's property list does not show any Event Procedures. I couldn't find an AfterInsert event on the prop list.

I'm still trying to figure out how to use the debugging features among other things. Without explicit instruction I probably wouldn't be able to locate the code to paste here.

Other behaviors I should mention. Once I click ok on the error message the form will open additional records w/o the error msg. Also there are a couple other forms that will open/close w/o error which would seem to support the theory that the error is triggered by this particular form (which unfortunately is the primary record entry method). I can use the db with this nuisance but would like to figure out what's causing it.
 
You're welcome.
Well that's just confusing and now I'm taking shots in the dark, but would you be able to;

post all the code on your form here.
or
Post the entire db file?
 
I brought the form ("Transaction") up in design, switched to database tools, then VB. This is the code that came up:

Option Compare Database
Option Explicit
Private Sub Check61_AfterUpdate()

End Sub

Private Sub Form_Close()

End Sub

Private Sub Form_Open(Cancel As Integer)

End Sub

Private Sub New_Customer_Click()
On Error GoTo Err_New_Customer_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_New_Customer_Click:
Exit Sub

Err_New_Customer_Click:
MsgBox Err.Description
Resume Exit_New_Customer_Click

End Sub
Private Sub New_Vendor_Click()
On Error GoTo Err_New_Vendor_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Vendors"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_New_Vendor_Click:
Exit Sub

Err_New_Vendor_Click:
MsgBox Err.Description
Resume Exit_New_Vendor_Click

End Sub
Private Sub List51_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me!
[List51])
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Combo53_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Me![Combo53])
Me.Bookmark = rs.Bookmark
End Sub

Private Sub Next_Record_Click()
On Error GoTo Err_Next_Record_Click


DoCmd.GoToRecord , , acNext

Exit_Next_Record_Click:
Exit Sub

Err_Next_Record_Click:
MsgBox Err.Description
Resume Exit_Next_Record_Click

End Sub
Private Sub Save_Record_button_Click()
On Error GoTo Err_Save_Record_button_Click

DoCmd.RunCommand acCmdSaveRecord

Exit_Save_Record_button_Click:
Exit Sub

Err_Save_Record_button_Click:
MsgBox Err.Description
Resume Exit_Save_Record_button_Click

End Sub
Private Sub Go_to_last_record_Click()
On Error GoTo Err_Go_to_last_record_Click

DoCmd.GoToRecord , , acLast

Exit_Go_to_last_record_Click:
Exit Sub

Err_Go_to_last_record_Click:
MsgBox Err.Description
Resume Exit_Go_to_last_record_Click

End Sub
Private Sub Previous_record_Click()
On Error GoTo Err_Previous_record_Click

DoCmd.GoToRecord , , acPrevious

Exit_Previous_record_Click:
Exit Sub

Err_Previous_record_Click:
MsgBox Err.Description
Resume Exit_Previous_record_Click

End Sub
Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

If Me.Dirty Then Me.Dirty = False
DoCmd.Close

Exit_Close_Form_Click:
Exit Sub

Err_Close_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Form_Click
End Sub
 
Well, I see nothing out of the ordinary except for the first three subs which have nothing in them. Go ahead and replace all of that with this, and see if it helps. If you still get the same error, I would decompile the file and then recompile once more. We can help you do that if needed.

Code:
Option Compare Database
Option Explicit

Private Sub New_Customer_Click()
On Error GoTo Err_New_Customer_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
        stDocName = "Customers"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_New_Customer_Click:
    Exit Sub
Err_New_Customer_Click:
    MsgBox Err.Description
    Resume Exit_New_Customer_Click
End Sub

Private Sub New_Vendor_Click()
On Error GoTo Err_New_Vendor_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    
        stDocName = "Vendors"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
    
Exit_New_Vendor_Click:
    Exit Sub
Err_New_Vendor_Click:
    MsgBox Err.Description
    Resume Exit_New_Vendor_Click
End Sub

Private Sub List51_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID] = " & Str(Me![List51])
        Me.Bookmark = rs.Bookmark

End Sub

Private Sub Combo53_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object
    
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[ID] = " & Str(Me![Combo53])
        Me.Bookmark = rs.Bookmark

End Sub

Private Sub Next_Record_Click()
On Error GoTo Err_Next_Record_Click

    DoCmd.GoToRecord , , acNext

Exit_Next_Record_Click:
    Exit Sub
Err_Next_Record_Click:
    MsgBox Err.Description
    Resume Exit_Next_Record_Click
End Sub

Private Sub Save_Record_button_Click()
On Error GoTo Err_Save_Record_button_Click

    DoCmd.RunCommand acCmdSaveRecord

Exit_Save_Record_button_Click:
    Exit Sub
Err_Save_Record_button_Click:
    MsgBox Err.Description
    Resume Exit_Save_Record_button_Click
End Sub

Private Sub Go_to_last_record_Click()
On Error GoTo Err_Go_to_last_record_Click

    DoCmd.GoToRecord , , acLast

Exit_Go_to_last_record_Click:
    Exit Sub
Err_Go_to_last_record_Click:
    MsgBox Err.Description
    Resume Exit_Go_to_last_record_Click
End Sub

Private Sub Previous_record_Click()
On Error GoTo Err_Previous_record_Click

    DoCmd.GoToRecord , , acPrevious

Exit_Previous_record_Click:
    Exit Sub
Err_Previous_record_Click:
    MsgBox Err.Description
    Resume Exit_Previous_record_Click
End Sub

Private Sub Close_Form_Click()
On Error GoTo Err_Close_Form_Click

    If Me.Dirty Then Me.Dirty = False
    DoCmd.Close

Exit_Close_Form_Click:
    Exit Sub
Err_Close_Form_Click:
    MsgBox Err.Description
    Resume Exit_Close_Form_Click
End Sub
 
Replaced code, still getting error message. Don't know if this will help but attached is zip of the form (using your code or mine) with the error. Don't have enough posts to display it directly.

Ref the snapshot, if my first action is to click the advance record button at the bottom (1 of 196), the error will occur, but clicking "OK" on the error msg will advance the record. Error will occur on each successive record advance.

If my first action is, for example, clicking the "Transaction Type" dropdown, the error will occur at this time, however, no further errors will occur on any action, including record advance.
 

Attachments

I'd like to see what you have in the rowsource property of the Transaction Type comboBox.
I also noticed that you have a subform. You may want to look at the code on that subform, if there is any.
 
Row Source: Buy;Sell;Resource;Other
Row Source Type: Value List

The transactions subform is basically just a record list. I opened it and it will transition between records w/o an error msg. I don't know how to get the code for this. When I open it then click on VB the display reverts to the transaction form. ? .

Thx again for your help.
 

Users who are viewing this thread

Back
Top Bottom