IsLoaded error

G

Guest

I have the following code in a report that I'm trying to get to print from a
form.

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmPrintYardSaleApplication", , , , , acDialog
If Not IsLoaded("frmPrintYardSaleApplication") Then
Cancel = True
End If
End Sub

I copied this from an Event Management Access database that was on the
Microsoft Website. This program had a button on a form that would print an
invoice when selected. It did this by first calling a report object that then
called a form object that would print the report. At least I think that's the
way it did it. I'm relatively new to this and still working my way through. I
took this and tried to adapt it to my program, but when I try to preview the
report I get a VB error:

"Compile Error
Sub or Function not defined" - and the IsLoaded word is highlighted.

I have checked all the places I know to check to make sure that the name for
the form is correct and it is...at least where I know to check. If anyone
could point me in the right direction I would appreciate it. Thanks to
everyone who have helped me in the past and hopefully will in the future. One
day maybe I'll be able to 'pass it on' after I get fluent enough in Access
and VBA.

Thanks,
Randy M
 
B

Brian Bastl

You need to import the IsLoaded() function from the Event Management db into
your db.

HTH,
Brian
 
B

Brendan Reynolds

IsLoaded is a custom function, not a built-in one. Look in the modules of
the same database you got the posted code from, and you'll find an IsLoaded
function in one of them. Copy that module into your own database and your
code will work.
 
D

Douglas J Steele

IsLoaded isn't a built-in function in Access.

Go back to the database you got that code snippet from, search through the
modules for the IsLoaded function and copy it into your database as well.
 
G

Guest

Douglas,
Thanks for your help. I found the code. I'm learning about Access & VB as
I go. I did an F1 on the IsLoaded word and found it was a property. I guess I
just assumed it was also a function in Access and not a custom one.

RandyM.
 
G

Guest

Brian,
Thank you for your suggestion. I hate to sound like an idiot, but I guess
I am in some areas. How would I go about importing the IsLoaded Function from
the other db into the new one? I saw something about importing, but I didn't
notice it referring to VB code, just tables and such.

Thanks again,
Randy M
 
G

Guest

Brendan,
Thanks for the info, I found it and have copied it over. Now, to check it
out.

Randy M
 
B

Brendan Reynolds

The property is not the same as the function of the same name. The property
is built-in, but the function is not.

The property was new in Access 2000. Microsoft had been using the function
of the same name in their sample databases for many versions before that.

There are differences in the way the property and the custom function
behave. The property will return True if the object is open in design view,
while the function will not - at least, the version I'm familiar with will
not - there have been different versions of the function in different sample
databases.

There are also differences in the way the property and the function are
used. To determine whether a form is open using the IsLoaded property ....

If CurrentProject.AllForms("NameOfFormHere").IsLoaded Then

.... whereas, to determine if the same form is open using the function ...

If IsLoaded("NameOfFormHere") Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top