ACC2000: "An unknown error has occurred" Error Setting Form's Maximum Record Limit or Server Filter

ID: Q223204


The information in this article applies to:

Advanced: Requires expert coding, interoperability, and multiuser skills.

This article applies only to a Microsoft Access project (.adp).


SYMPTOMS

When you do any of the following things

you may receive the following error message:
An unknown error has occurred.


RESOLUTION

Resolving the Maximum Record Limit

You can disable the built-in Max Rec button and create a custom button on your form to set the maximum number of records. The following steps show you an example of how to do this.
  1. Open the sample Microsoft Access project NorthwindCS.adp.


  2. Create a new form based on the Customers table.


  3. Set the MaxRecButton property of the form to No.


  4. Add a command button to the form and set the following properties:


  5. 
       Name: cmdMaxRecs
       Caption: Max Records 
  6. On the View menu, click Code, and type the following code:


  7. 
    Dim rs As New ADODB.Recordset
    
    Private Sub cmdMaxRecs_Click()
    
       Dim strSQl as String
    
       Set rs = Nothing
    
       'Type your own SQL statement.
       strSQl = "SELECT * FROM Customers"
    
       rs.MaxRecords = CLng(InputBox("Type desired maximum ", _
         "Max Records", 10))
       rs.Open strSQL, CurrentProject.Connection, adOpenKeyset
       Set Me.Recordset = rs
    
    End Sub 
  8. Close the Visual Basic Editor.


  9. On the View menu, click Form View.

    Note that using the SQL statement provided, there are 91 records.


  10. Click Max Records, and then click OK.

    Note that there are only 10 records now.


Resolving the Server Filter By Form

You can create a custom button on your form to filter the number of records. The following steps show you an example of how to do this.
  1. Open the sample Access project NorthwindCS.adp.


  2. Create a new unbound form.


  3. Set the Server Filter By Form property to No.


  4. Add a text box to the form and set the ControlSource property a follows:


  5. 
        CompanyName 
  6. Add a combo box to the form and set the following properties:


  7. 
       Name: cmbCusts
       RowSource: Customers
       ColumnWidths: 1" 
  8. Add a command button to the form and set the following properties:


  9. 
       Name: cmdFilter
       Caption: Filter 
  10. On the View menu, click Code, and type the following code:


  11. 
    Private Sub cmdFilter_Click()
        Me.FilterOn = True
        Me.Filter = "[CustomerID] = '" & Me!cmbCusts & "'"
    End Sub 
  12. Save and run the form.


Resolving F9 or Shift+F9

Disable F9 or Shift+F9 by using AutoKeys. The following steps show you an example of how to do this.
  1. Open a new macro in Design view.


  2. On the View menu, click Macro Names.


  3. Create the following macro:


  4. Macro Name Action
    {F9} Beep
    +{F9} Beep

  5. Close and save the macro as AutoKeys.



STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.


MORE INFORMATION

Steps to Reproduce Problem

Using Maximum Record Limit

  1. Open the sample Access project NorthwindCS.adp.


  2. Create a new unbound form.


  3. Add a text box to the form and set the ControlSource property as follows:


  4. 
       CompanyName 
  5. On the View menu, click Code.


  6. Add the following code to the line or lines of code already there:


  7. 
    Dim rs As New ADODB.Recordset
    
    Private Sub Form_Load()
       rs.Open "SELECT * FROM Customers", _
         CurrentProject.Connection, adOpenKeyset
       Set Me.Recordset = rs
    End Sub 
  8. Close the Visual Basic Editor.


  9. On the View menu, click Form View.


  10. Click the Maximum Record Limit button, type a value of 10, and press ENTER. Note that you receive the error:


  11. An unknown error has occurred.
  12. Click OK and then press F9. You receive the error again.


Using Server Filter By Form

  1. Open the sample Access project NorthwindCS.adp.


  2. Create a new unbound form.


  3. Set the ServerFilterByForm property to Yes.


  4. Add a text box to the form and set the ControlSource property as follows:


  5. 
        CompanyName 
  6. On the View menu, click Code.


  7. Add the following code to the line or lines of code already there:


  8. 
    Dim rs As New ADODB.Recordset
    Private Sub Form_Load()
        rs.Open "SELECT * FROM Customers", _
            CurrentProject.Connection, adOpenKeyset
        Set Me.Recordset = rs
    End Sub 
  9. Close the Visual Basic Editor and on the View menu, click Form View.


  10. Select Is Not Null from the drop-down box, and click the Apply Server Filter button on the toolbar. Note that you receive the following error message:


  11. An unknown error has occurred.
  12. Click OK to the message and another message appears:


  13. Microsoft Access didn't apply the filter.
  14. Click Yes. You receive the following error again:
    An unknown error has occurred.


Additional query words: pra


Keywords          : kbdta AccessCS 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: June 1, 1999