User-defined type not defined

J

Jaroslav Beran

In MS Access 2000 when I try to compile VBA code
message "User-defined type not defined".
What is strange to me is that this message appears even
when all VBA code is in comment.
Does anybody know what can cause this error?

Thanks

Jaroslav Beran
 
A

Allen Browne

From the code window, choose References on the Tools menu, and check the box
beside:
Microsoft DAO 3.6 Library
Explanation:
http://members.iinet.net.au/~allenbrowne/ser-38.html

The problem shoud not occur if the offending code has been commented out.
Did you comment it out in break mode (i.e. while the code is running)? It
may be worth trying a decompile. Make a copy of the database, and enter
something like this at the command prompt while Access is not running. It is
all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
 
J

Jaroslav Beran

I'm sorry I didn't mentioned earlier that MS DAO 3.6 is
allready referenced. That's not the point.
And all VBA code is commented out - it was commented in
design mode, not in break mode.
Anyway - the /DECOMPILE switch solved my problem, for what
I'm in your debt.
I've never heard about this switch before - is this some
kind of black magic?
Thank you
Jaroslav Beran
-----Original Message-----
From the code window, choose References on the Tools menu, and check the box
beside:
Microsoft DAO 3.6 Library
Explanation:
http://members.iinet.net.au/~allenbrowne/ser-38.html

The problem shoud not occur if the offending code has been commented out.
Did you comment it out in break mode (i.e. while the code is running)? It
may be worth trying a decompile. Make a copy of the database, and enter
something like this at the command prompt while Access is not running. It is
all one line, and include the quotes:
"c:\Program Files\Microsoft
office\office\msaccess.exe" /decompile
 
A

Allen Browne

Jaroslav Beran said:
... the /DECOMPILE switch solved my problem ...
I've never heard about this switch before - is this some
kind of black magic?

Access stores 2 versions of the code:
- the text version (what you view and edit),
- the compiled version (machine type code that actually runs).

Under certain conditions, it is possible for these to get out of sync, so
the compiled code no longer matches the text you are viewing, i.e. a
corruption has crept into the database. The Decompile switch instructs
Access to dump the compiled version. It can then recompile from the text,
and you are back in sync. Of course, if it was the text version that was
wrong, you're in trouble, so we always recommend backing up before
decompiling.

IME, editing the code in break mode is one of the causes of this kind of
corruption. When you modify an object, Access creates a temporary copy so
that you are able to revert to the previously saved object. At this point it
would appear that it is trying to manage 4 copies of the: text and compiled
of current form, and text and compiled of the temp form. If you are in break
mode at the point when it creates the temp copy, then at some point it seems
to get these copies confused, and the compiled code no longer matches the
text version. I cannot demonstrate that this what happens, but I think the
circumstantial evidence is strong.
 
J

Jaroslav Beran

IME, editing the code in break mode is one of the causes
of this kind of
corruption. >--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


O.K. - so another thing to avoid when writing code is
editing in break mode. Maybe it was the cause of my
problem, because I edited the code in break mode.

Thank you for the exhausting explanation.

Jaroslav Beran
 

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