Help Finding Where "User-defined type not defined" Is Coming From

J

Jay Chan

I am trying to compile my MS-Access MDB program. But I got this error
message:

"User-defined type not defined"

Unfortunately, I cannot see which part of the source code that the
error message is referring to. Therefore, I don't know which data-type
it is complaining about.

Let me explain how I got to this:

- In order to fix the "Startup Module Keep Failed to Startup"
problem, I want to recompile all the programs in the MDB file.

- When the first time I compiled it, I got the error message
"User-defined type not defined", and I saw that MS-Access had
highlighted the statement referring to CurrentDb object. CurrentDb is
old DAO stuff, and I haven't added references to DAO stuff (and I
don't plan to do so). That explains the reason why I got that error
message. Fine. I rewrote that part of the program to use
Application.CurrentProject instead of CurrentDb (no big deal - just 10
lines of code).

- When I try to compile again, I got the same error message. But
this time MS-Access doesn't highlight anything in my code. Therefore,
I don't know which part of the program is causing that error message.

- Adding a reference to either "Microsoft DAO 2.5/3.51 Compatibility
Library" or "Microsoft DAO 3.6 Object Library" doesn't fix the
problem. I still get the same error message.

- Re-starting MS-Access doesn't fix the problem.

- The problem has nothing to do with whichever form that I happen to
have opened in VBA screen.

- Removing and re-inserting the code-module that used to use
CurrentDb doesn't fix the problem either.

- Eye-balling all the code modules doesn't find any statement that
is being highlighted.

How can I get rid of that error message?

Pleas help. Thanks.

Jay Chan
 
A

Albert D. Kallal

At least you are getting the database a bit in order.

When developing code, I *always* do a save a compile to prevent errors. One
can develop for a long time, and pile up error after error. The result can
be one real large mess.

Anyway, the first thing I would do is a compact and re-pair. That may very
well fix this problem right after the bat.

The next thing I would check is the references, and make sure none are
marked as "missing". For info on references....check out:

Allen Browne
http://users.bigpond.net.au/abrowne1/ser-38.html

Doug Steele:
http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html

Peter Walker:
http://www.papwalker.com/dllhell/index-page2.html


MsKb Articles: 310803, 208218, 209849, 286300

ACC2000: How Access 2000 Resolves Visual Basic for Applications References
http://support.microsoft.com/default.aspx?scid=kb;en-us;248941

ACC2000: How to Resolve Reference Issues in an Access Database
http://support.microsoft.com/default.aspx?scid=kb;en-us;310803

You also may have a corrupted mdb file. You might try and import everything
into a new file, and see if that helps.
 
D

Douglas J. Steele

Just create a new database, and use File | Get External Data to import
everything from the old database.

What's the actual line that was failing with the CurrentDb reference? I've
found that sometimes it highlights the wrong part of a line when there's an
error, so that something other than the CurrentDb reference may have been
the culprit.

Also, if none of the references have "MISSING:", select an additional
reference at random, back out of the dialog, then go back in and unselect
the reference you just added. If that doesn't solve the problem, try to
unselect as many of the selected references as you can (Access may not let
you unselect them all), back out of the dialog, then go back in and reselect
the references you just unselected. (NOTE: write down what the references
are before you delete them, because they'll be in a different order when you
go back in)
 
J

Jay Chan

Anyway, the first thing I would do is a compact and re-pair. That may very
well fix this problem right after the bat.

Unfortunately, using the Database Repair tool doesn't fix the problem.
The next thing I would check is the references, and make sure none are
marked as "missing".

None are marked as missing.
You also may have a corrupted mdb file. You might try and import everything
into a new file, and see if that helps.

I am afraid that this may be what I need to do. Is there a way to
export the whole MDB (forms and code modules) and to import it back to
a brand-new MDB?

Thanks.

Jay Chan
 
J

Jay Chan

Just create a new database, and use File | Get External Data to import
everything from the old database.

Thanks. This gets rid of the phantom compiler-error.

I was looking for a way to "export" the info from my MS-Access
program. Actually I should have been looking for a way to "import"
info into a MS-Access MDB file as what you have suggested.
What's the actual line that was failing with the CurrentDb reference? I've
found that sometimes it highlights the wrong part of a line when there's an
error, so that something other than the CurrentDb reference may have been
the culprit.

I am sure that the original compiler-error has to do with CurrentDb.
First of all, the CurrentDb statment was highlighted. Secondly,
CurrentDb requires the reference to DAO, and I have chosen not to link
the DAO reference. I have chosen not to use DAO syntax in order to
avoid the confusion of having both DAO and ADO in one program.
Also, if none of the references have "MISSING:", select an additional
reference at random, back out of the dialog, then go back in and unselect
the reference you just added. If that doesn't solve the problem, try to
unselect as many of the selected references as you can (Access may not let
you unselect them all), back out of the dialog, then go back in and reselect
the references you just unselected. (NOTE: write down what the references
are before you delete them, because they'll be in a different order when you
go back in)

This was not the case. But I will make a note on this. Next time if I
have a problem that I cannot resolve, I will try this tip. Thanks.

Jay Chan
 

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