ppincetl
ppincetl

Reputation: 19

Runtime error 3000 and Reserved Error (-3087) Access 2010 macro/VBA

Using Access 2010, I have entry cells for a table that span 5 separate forms, and I have created command buttons on each form to navigate between them, filtering the next form for the ID on the current form. Four of the five command buttons work just fine to filter to the proper form, but the command buttons associated with one form feedback an error message reading:

Reserved Error (-3087); there is no message for this error.

I have used both macros and VBA to navigate between the forms, using either OpenForm with a filter on the Where Condition or DoCmd.OpenForm. The Macro looks like:

Open Form
     Form Name "MyForm"
     View Form
     Filter name
     Where condition =="[ID]=" & [ID]
     Data mode
     Window mode Normal
Close Window
     Object Type Form
     Object Name "CurrentForm"
     Save No

And the VBA code looks like:

DoCmd.OpenForm _
  "MyForm" _
, acNormal, _
, "[ID] = " & [ID] _
, acFormEdit _
, acNormal

The VBA also feedback

Runtime Error 3000.

Google searches and searches of stack overflow have yielded nothing helpful. This error seemingly arose for no reason, as the command buttons worked fine before. And all the other command buttons linking to the other forms work just fine.

I'm guessing that the issue stems from the destination form, not the macro or VBA, but I can't seem to figure out a problem with it. I've:

(all of which result in the same error 3087)

Upvotes: 2

Views: 1571

Answers (1)

Wayne G. Dunn
Wayne G. Dunn

Reputation: 4312

I dislike creating an 'Answer' while trying to solve, but felt it was easier to communicate more instructions / ideas. I will delete or update this answer based on solving the issue.

Please review all of my statements and confirm I have correctly stated what has been done.

Background: Opening a form form another form, using either a macro or VBA DoCmd.OpenForm causes error 'Runtime error 3000 and Reserved Error (-3087)'

Your normal VBA is as follows:

DoCmd.OpenForm "MyForm", acNormal, , "[ID] = " & [ID], acFormEdit, acNormal

You can run the above code from the Immediate Window and delete the 'Where Condition' (ID = ID), then the form will open ok. Since [ID] is not in scope in the Immediate Window, you can't simply run the command with the 'Where' condition.

Is there ANY code in the form in the Open/Load/Resize/Activate/Current events?

Here is how I would proceed to debug:

  1. Clone that form, save it as 'Form3000'.
  2. Go to the code window, select ALL code and comment out.
  3. Obtain a valid 'ID' for testing.
  4. Create a subroutine in a new module as follows:

    Option Compare Database
    Option Explicit
    
    Sub Test3000()
    Dim MyID    As Long
    
    On Error GoTo Error_Trap
    MyID = InputBox("Enter a valid ID", "Enter Where COndition")
    'DoCmd.OpenForm "Form3000", acNormal, , "[ID] = " & [ID], acFormEdit, acNormal
    DoCmd.OpenForm "Form3000", acNormal, , "[ID] = " & MyID, acFormEdit, acNormal
    Exit Sub
    
    Error_Trap:
        Debug.Print Err.Number & vbTab & Err.Description
        MsgBox Err.Number & vbTab & Err.Description
        Exit Sub
        Resume              ' If needed later...
        Resume Next
    End Sub
    
  5. Execute the code, enter the valid ID.

  6. What happens?
  7. If it still fails, post the form property for Recordsource, Filter
  8. If it works, then uncomment all the code in the form and post it in your question.

Based on what happens, we can try other options.

Upvotes: 0

Related Questions