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
- 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.
RESOLUTIONResolving 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
- Close the Visual Basic Editor.
- On the View menu, click Form View.
Note that using the SQL statement provided, there are 91 records.
- 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.
- Open the sample Access project NorthwindCS.adp.
- Create a new unbound form.
- Set the Server Filter By Form property to No.
- Add a text box to the form and set the ControlSource property a follows:
CompanyName
- Add a combo box to the form and set the following properties:
Name: cmbCusts
RowSource: Customers
ColumnWidths: 1"
- Add a command button to the form and set the following properties:
Name: cmdFilter
Caption: Filter
- 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
- 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.
- Open a new macro in Design view.
- On the View menu, click Macro Names.
- Create the following macro:
Macro Name |
Action |
{F9} |
Beep |
+{F9} |
Beep |
- Close and save the macro as AutoKeys.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed
at the beginning of this article.
MORE INFORMATIONSteps to Reproduce Problem
Using Maximum Record Limit
- Open the sample Access project NorthwindCS.adp.
- Create a new unbound form.
- Add a text box to the form and set the ControlSource property as follows:
CompanyName
- On the View menu, click Code.
- 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
- Close the Visual Basic Editor.
- On the View menu, click Form View.
- 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.
- Click OK and then press F9. You receive the error again.
Using Server Filter By Form
- Open the sample Access project NorthwindCS.adp.
- Create a new unbound form.
- Set the ServerFilterByForm property to Yes.
- Add a text box to the form and set the ControlSource property as follows:
CompanyName
- On the View menu, click Code.
- 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
- Close the Visual Basic Editor and on the View menu, click Form View.
- 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.
- Click OK to the message and another message appears:
Microsoft Access didn't apply the filter.
- 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
|