"Cannot define a public user defined type within an object module" (1 Viewer)

U

u0107

Guest
Hello,

This is my first posting, so at the outset, let me apologise for any inadvertent transgressions or violations of any etiquette of this forum.
---------------------
I have been attempting to create an MDE for an application which I want to commercially sell. When I attempted to create it, I got a message saying "Microsoft Access was unable to create an MDE Database".

I posted this to another webboard where I was told that it could be a compilation error and that I could check that out by trying the "Compile" option in Run sub-menu in VBA editor. I did it and I got the following error:

"Cannot define a public user defined type within an object module."

This error occurs for a statement which reads:

"Public Type DisplaySettings"

in a Class Module "Screeninfo"

My help does not give any help on this:

Can someone help me on this please?

Thanks in advance.

Uttam
 

Mile-O

Back once again...
Local time
Today, 10:54
Joined
Dec 10, 2002
Messages
11,316
You have declared a Public Type within a form or report's module.

it should look something like this:

Code:
Public Type MyType
    ' declarations here
End Type

It should be moved to an independant module.
 
U

u0107

Guest
hello,

Actually this is a code from the Litwin, Getz and Gilbert developer's handbook set for A2K.

I just cut and pasted this as is into my code - it is the code which helps me determine the fonts installed on a client and populates a drop down box for selection.

If I comment it out and move it to the specific form where this dropdown box is, I get another error of Displaysettings not being defined.

Also when I examined the code further, I found some other instances of Public Type kind of declarations which once I grapple and solve these errors, I am sure will pop up!

Has anyone used this piece of code (available on Pages 1293-5) in Volume 1 of the Access Developer Handbook set?

Thanks in advance.

Uttam

----------------------
 

WayneRyan

AWF VIP
Local time
Today, 10:54
Joined
Nov 19, 2002
Messages
7,122
uttam,

I missed the "quotes" class last week, but Mile is right.

Move your code to a Public module. Go to your database
TAB, Modules, New and put your code there. Then all of
your forms, reports, etc. can access it.

You can't comment out parts of it, because ALL of it needs
to be accessible.

Wayne
 

Users who are viewing this thread

Top Bottom