Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable not defined error 2

Status
Not open for further replies.

mmiram

IS-IT--Management
Feb 4, 2005
45
US
Hi:

I am trying to run a report of a parameter query populated by a form.

I am using the method described under the heading "Creating a form to supply parameters to a report" in the link below


I even downloaded the same DB in the link and when I try to run the report, I get the following error in the module created

"Compile Error...variable not defined" and it opens up the VB editor with the following code...


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 highlighted and a yellow arrow points to the first line
"Function IsLoaded(ByVal strFormName As String) As Boolean"

And this happens with the sample DB I downloaded from Microsoft's web site. Is something wrong with my Access installation? Is it missing some libraries etc.

I am really confused. Any help will be appreciated.

Thanks,
Ram.
 
mmiram,

I believe you need to add a reference too.. Darn it's one of these...

Windows Script Host Object Model
or
Microsoft DAO 3.6 Object Library

Just press Alt + F11 then set your references..

I hope this helps...

[thumbsup2]


 
Hitechuser:

The DAO reference was already set. I set the Windows Script Host Object Model Reference but that did not solve the issue. I uninstalled and reinstalled office 2000 and that did not solve it. I finally installed office XP and it works in that. It still does not work in office 2000.
I wonder why? Maybe some of the references are corrupt.

Ram.
 
I don't think the acCurViewDesign constant exists in Access 2000 - I'm not entirely sure, either drop the line testing for design view, or try replacing it with 0 (the value of the constant in 2002).

Roy-Vidar
 
acCurViewDesign constant does not exist in Access 2000. Replace your code with this:

Function IsLoaded(ByVal strFormName As String) As Integer

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
End If
End If
End Function
 
Thank You guys, that was it...as soon as I replaced the code with yours it worked. I had to add "Isloaded=True" after the then condition. But everything works fine now.

Ram.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top