Microsoft KB Archive/223204

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

Article ID: 223204

Article Last Modified on 7/14/2004

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



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.



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.  Open the sample Microsoft Access project NorthwindCS.adp. Create a new form based on the Customers table. Set the MaxRecButton property of the form to No.  Add a command button to the form and set the following properties:   Name: cmdMaxRecs Caption: Max Records   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 </li> Close the Visual Basic Editor.</li> On the View menu, click Form View.

Note that using the SQL statement provided, there are 91 records.</li> Click Max Records, and then click OK.

Note that there are only 10 records now.</li></ol>

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. <ol> Open the sample Access project NorthwindCS.adp.</li> Create a new unbound form.</li> Set the Server Filter By Form property to No.</li>  Add a text box to the form and set the ControlSource property a follows: <pre class="fixed_text">   CompanyName </li>  Add a combo box to the form and set the following properties: <pre class="fixed_text">  Name: cmbCusts RowSource: Customers ColumnWidths: 1"                   </li>  Add a command button to the form and set the following properties: <pre class="fixed_text">   Name: cmdFilter   Caption: Filter                    </li>  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                    </li> Save and run the form.</li></ol>

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. <ol> Open a new macro in Design view.</li> On the View menu, click Macro Names.</li> Create the following macro:

</li> Close and save the macro as AutoKeys.</li></ol>

<div class="status_section">

STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

<div class="moreinformation_section">

Using Maximum Record Limit
<ol> Open the sample Access project NorthwindCS.adp.</li> <li>Create a new unbound form.</li> <li> Add a text box to the form and set the ControlSource property as follows: <pre class="fixed_text">  CompanyName </li> <li>On the View menu, click Code.</li> <li> 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 </li> <li>Close the Visual Basic Editor.</li> <li>On the View menu, click Form View.</li> <li>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.

</li> <li>Click OK and then press F9. You receive the error again.</li></ol>

Using Server Filter By Form
<ol> <li>Open the sample Access project NorthwindCS.adp.</li> <li>Create a new unbound form.</li> <li>Set the ServerFilterByForm property to Yes.</li> <li> Add a text box to the form and set the ControlSource property as follows: <pre class="fixed_text">   CompanyName </li> <li>On the View menu, click Code.</li> <li> 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 </li> <li>Close the Visual Basic Editor and on the View menu, click Form View.</li> <li>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.

</li> <li>Click OK to the message and another message appears:

Microsoft Access didn't apply the filter.

</li> <li>Click Yes. You receive the following error again:

An unknown error has occurred.

</li></ol>

Additional query words: pra

Keywords: kbbug kbclientserver kbpending KB223204

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.