ACC2000: "An Unknown Error Has Occurred" Error Setting Form's Maximum Record Limit or Server Filter (223204)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q223204
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
  • click the Maximum Record Limit button
  • click the Server Filter By Form button
  • press F9
  • press Shift+F9
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:
       Name: cmdMaxRecs
       Caption: Max Records
    					
  5. On the View menu, click Code, and type the following code:
    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
    					
  6. Close the Visual Basic Editor.
  7. On the View menu, click Form View.

    Note that using the SQL statement provided, there are 91 records.
  8. 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:
        CompanyName
    					
  5. Add a combo box to the form and set the following properties:
       Name: cmbCusts
       RowSource: Customers
       ColumnWidths: 1"
    					
  6. Add a command button to the form and set the following properties:
       Name: cmdFilter
       Caption: Filter
    					
  7. On the View menu, click Code, and type the following code:
    Private Sub cmdFilter_Click()
        Me.FilterOn = True
        Me.Filter = "[CustomerID] = '" & Me!cmbCusts & "'"
    End Sub
    					
  8. 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:
    Macro NameAction
    {F9}Beep
    +{F9}Beep

  4. Close and save the macro as AutoKeys.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are 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:
       CompanyName
    					
  4. On the View menu, click Code.
  5. Add the following code to the line or lines of code already there:
    Dim rs As New ADODB.Recordset
    
    Private Sub Form_Load()
       rs.Open "SELECT * FROM Customers", _
         CurrentProject.Connection, adOpenKeyset
       Set Me.Recordset = rs
    End Sub
    					
  6. Close the Visual Basic Editor.
  7. On the View menu, click Form View.
  8. Click the Maximum Record Limit button, type a value of 10, and press ENTER. Note that you receive the error:
    An unknown error has occurred.
  9. 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:
        CompanyName
    					
  5. On the View menu, click Code.
  6. Add the following code to the line or lines of code already there:
    Dim rs As New ADODB.Recordset
    Private Sub Form_Load()
        rs.Open "SELECT * FROM Customers", _
            CurrentProject.Connection, adOpenKeyset
        Set Me.Recordset = rs
    End Sub
    					
  7. Close the Visual Basic Editor and on the View menu, click Form View.
  8. 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:
    An unknown error has occurred.
  9. Click OK to the message and another message appears:
    Microsoft Access didn't apply the filter.
  10. Click Yes. You receive the following error again:
    An unknown error has occurred.

Modification Type:MinorLast Reviewed:7/14/2004
Keywords:kbbug KbClientServer kbpending KB223204