ACC: Error Using More Than 2000 Characters in WhereCondition of OpenReportID: Q184948
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you run a procedure that contains the OpenReport method of the DoCmd
object, and you use the WhereCondition argument to pass a string that
contains more than 2000 characters, the report may not open. You may also
receive one of the following error messages:
- Run-time error '2465':
Microsoft Access can't find the field <field name> referred to in your expression.
You may have misspelled the field name, or the field may have been renamed or deleted.
- Run-time error '3464':
Data type mismatch in criteria expression.
- No current record.
- Out of memory.
You can use two methods to filter a report without limitation on the size of the WHERE clause.
Microsoft has confirmed this to be a problem in Microsoft Access versions 7.0 and 97.
Sub ReportWhereTest()
Dim strPWhr As String
' Build a Where clause that is 2046 characters long.
strPWhr = "[Phone] in ('" & String(2031, "a") & "')"
' Show how long the WhereCondition is.
MsgBox Len(strPWhr) & " Characters"
' Open the report with the WhereCondition.
DoCmd.OpenReport "rptWhereTest", acViewPreview, , strPWhr
' If you are using Microsoft Access 7.0, comment out the
' previous line that contains the OpenReport method by typing
' an apostrophe at the beginning of that line. Then remove
' the apostrophe from the beginning of the following line:
' DoCmd.OpenReport "rptWhereTest", acPreview, , strPWhr
End Sub
For more information about the OpenReport method, search the Help Index for "OpenReport method," or ask the Microsoft Access 97 Office Assistant.
Keywords : kberrmsg kbdta MdlProb
Version : WINDOWS:7.0,97
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 22, 1999