2
votes

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:

-enabled the database in the Trust Center -tried using a tempVar to filter the form -tried opening a blank form with an "OnLoad" event

(all of which result in the same error 3087)

Any ideas?

1
There are way too many pieces to this puzzle to make an educated guess, so I suggest that you break this down to something simple. Please confirm that you get the error on the 'DoCmd.OpenForm'? First I would manually open that form and make sure it works. Open your VBA Project and paste the following in the immediate window and execute it: DoCmd.OpenForm "MyForm", acNormal, , "[ID] = " & [ID], acFormEdit, acNormal Based on the success or failure, then we can move to step 2.Wayne G. Dunn
At the risk of exposing myself as a VBA rookie, I've done this and recieved "Compile Error: External Name not defined". I am able to pull up the form from the objects panel, and access it from a navigation form that is apart from the data entry forms. However, when I select "toggle filter" in the home ribbon of the GUI it also gives the 3087 error.ppincetl
Did you change 'MyForm' to be your form name? Rats, sorry I see... you don't have '[ID]' in this context. Just remove the filter and try again.Wayne G. Dunn
I did change the form name for the immediate window attempt. And I attempted the immediate window in absence of the filter (except as applied by the OpenForm). In fact, if I drop the "Where" clause out of the OpenForm command the command pulls up an unfiltered copy of the form. As for the filter, I was trying it as another solution and hoping to narrow the issue down to problems with the filtering. I guess I wasn't precise enough in my previous comment. I did nothing else but pull up the desired form from the object panel and click to "toggle filter" button and it gave me the 3087 error.ppincetl
If you were able to open as an unfiltered form from the immediate window, but it gives an error if you toggle the filter, I would: (1) open in design view and check Recordsource ... is it a table or a query? does it look ok? (2) Check the Filter property, FilterOn, Allow Filters, etc. and see if something is out of place from what it should be.Wayne G. Dunn

1 Answers

0
votes

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.