code errors

  • Thread starter Thread starter Valerie
  • Start date Start date
V

Valerie

I was given a "skeleton" copy of an inventory database an
acquaintance created using an Access 97 template. I am
running it in Access 2000.

My first step was to see what it was made of. The
switchboard did not come up, but there was a switchboard
listed in the forms objects. When I tried to pull it up I
got a VB error message "Compile error: User-defined type
not defined", and "dbs As Database" was highlighted
after "Dim". (As you can probably tell, I know nothing
about code.)

Then, in trying to run the various reports, I keep
getting another VB error message "Compile error: Sub or
Function not defined" and "IsLoaded" is highlghted in the
following string "If Not IsLoaded ("ReportDateRange")
Then ... in 2 of the reports and "If Not IsLoaded
("PurchaseOrders") Then ... in another report.

Is this something any idiot can fix or is it over my
head?

Thanks in advance for any help you can provide.

Val
 
Val,

Open any code module, and select References from the Tools menu. You
need to have a tick next to 'Microsoft DAO 3.6 Object Library'. Find
this item in the list and tick the checkbox. Should be ok after this...
if not, please post back and we'll try something else :-)
 
Steve,
I don't know what happened. It worked the first time I
tried it, but now it doesn't work again. This time the
error says "Expected variable or procedure, not
module". "IsLoaded" is still highlighted, but when I
click on OK on the error message the following string is
highlighted: "Private Sub Report_Open(Cancel As Integer)".

Does this make any sense?

I went to the helps and followed a suggestion that I open
the Northwind db and copy the IsLoaded module, then paste
it into my db. That is actually what worked the first
time around because "references" was grayed out on the
tools menu. When I have the module open, I can access the
references menu and I have turned on the checkbox you
referred to. Still no help.

Does this have anything to do with A) the fact that this
was created in '97 and I'm using 2000 or B) the fact that
I am using Windows and Office XP on my computer but
Access 2000?

Thanks again for any wisdom you can impart.

Val
 
Val,

Hmmm. I was afraid it might be more complicated than just the DAO
thing. There should have already been an IsLoaded function set up
somewhere in the database, otherwise the Access 97 version wouldn't have
worked. In other words, there should have been no reason for you to
copy the function from Northwind. You can track this down by opening
any module and then go to Edit|Find and search for IsLoaded with the
Current Project option selected, and see if it turns up something like
Public Function IsLoaded(blabla) As Boolean
.... apart from the one you put in there.
Now, when you copied the one from Northwind, did you name the module
IsLoaded? If so, this will cause errors. Change it to something else.

Ok, let's look at those aspects first, and then see how it goes.

By the way, this has nothing to do with what version of Windows you are
using. The DAO factor is simply a result of the fact that Access 2000
does not set a reference to the DAO library by default, whereas other
versions do, and your database was using a DAO object in the code you
quoted in your original post.
 
Steve,

I had previously tried the second part of your
suggestion - naming the one I copied from Northwind
something other than "IsLoaded"...to no avail.

So I tried your first suggestion, searching for it
elsewhere. "IsLoaded" turned up frequently...but only in
the very reports I was unable to open in the first place,
and never with the "as Boolean".

I did see something else as I was searching, though, that
may or may not have anything to do with anything. You
suggested that it would say "Public" Function, etc.
Everything in this code starts with "Private". Does that
mean anything? I couldn't find "Public" anywhere.

As I was looking through all of this I came across
another issue that's bound to give me problems. I have
renamed many of the fields built into this database. I've
been very careful to check all my forms & queries for
conflicts, but now I see that these modules are chock
full of the original field names. Changing them is no
problem, but what I don't know is how to access all the
modules related to this project. When I click on Modules
on the objects menu, nothing is there but the one I
added.

You're a gem for taking the time to go through all this
with me. Thanks a million.

Val
 
Val,

IsLoaded is the name of the function. It's what is known as a
user-defined function, since it is not one of Access's builtin
functions. It needs to go in a public module, i.e. one which is seen in
the Modules tab of the database window, but it is important that the
module itself not be named IsLoaded, or any other conflicting name for
that matter. In this context, I would normally use the Public keyword
as in Public Function... but in this context, the Public is not
essential, and the one you have might just say Function... but if it
says Private Function... then this is wrong.

It sounds like all the other code in the database is in form or report
class modules. These modules are not seen in the Modules tab of the
database window. They are "behind" the forms and reports that they are
associated with. In these cases, it is normally correct for the
procedures to be Private, in other words they only apply within the
confines of that particular form or report. One way to find these is to
open each form or report in design view, and then select Code from the
View menu. Good luck with propogating your filedname changes through
the code!
 
Back
Top