Hi Doug and Jy,
I just downloaded the sample and did some testing. Changing:
If oAccessObject.CurrentView <> acCurViewDesign Then
to
If oAccessObject.CurrentView <> 0 Then
does not help, because one then receives a run-time error 438, Object
doesn't support this property of method, with this line of code highlighted
in yellow:
If oAccessObject.CurrentView <> 0 Then
However, there is an easy fix. The IsLoaded function from the copy of
Northwind that comes with Access 2000 can be substituted for the current
IsLoaded function. Here it is (watch for line wrap):
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <>
conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If
End Function
Tom
http://www.access.qbuilt.com/html/expert_contributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________
:
As I said in another post, acCurViewDesign only appears to exist in Access
2002 and Access 2003, and you're using Access 2000. (The page you're citing
is labelled "Access 2003/2002 Sample: Using Parameters with Queries and
Reports Sample Database")
See whether changing
If oAccessObject.CurrentView <> acCurViewDesign Then
to
If oAccessObject.CurrentView <> 0 Then
solves the problem.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
__________________________________________
Douglas,
Here is the link for sample database "Using parameters with queries and
reports sample database":
http://www.microsoft.com/downloads/...9A-315F-4138-8A63-0AC8E6A3AC0C&displaylang=en
I have checked the reference(Tool | reference in VB editor). There are
listed lots of objects. I only check 4 box: " Visual Basic for Application",
"Microsoft Access 9.0 objects library", "OLE Automation", "Microsoft ActiveX
data objects 2.1 library", "Microsoft DAO 3.6 object library". All others are
not checked. Should I check some of the left ?
When I ran the sample "sales by category report", the error message is
coming from:
Option Compare Database
Option Explicit
Public bInReportOpenEvent As Boolean ' Is report in the Open event?
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
Dim oAccessObject As AccessObject
Set oAccessObject = CurrentProject.AllForms(strFormName)
If oAccessObject.IsLoaded Then
If oAccessObject.CurrentView <> acCurViewDesign Then
IsLoaded = True
End If
End If
End Function
acCurViewDesign is not defined. Please let me know when you have any idea
on that. Thanks.
Happy Holiday.
Jy