> When I use a "Type" statement in VBA's class module, I get an error.
> Is there any way to get around this problem?
>
> Thanks,
>
> Eddie

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Hi Dirk,
Thanks for taking my question. I am new to MS Access (first time
user/developer) and I am developing most of the application in Visual Basic.
I have been having several problems. This is just one of many. Below is a
code snippit that mimics the problem.
I defined an object in the Class Module that looks simular to this: The
file name is clsType
-----------
Option Compare Database
Option Explicit
Public Type myType
a As Integer
End Type
-----------------------------
I defined a global variable referencing this object in the MS Access Class
Object Section: Form_ myForm. The variable is defined in the Declaration
Section of the Form_myForm object (For Exampel: DIM g as clsType).
Afer the global declaration section, I have the "Private Sub Form_Load()"
routine where I created a reference variable using the new statement: (g =
new clsType).
When I save the file and run the form I get the following error:
"The Expression ON LOAD you entered as an Event Property Setting Created
the Following Error: Cannot define a public user-defined type within an
object module ..."
Any help is greatly appricated,
Thanks,
Eddie
> > When I use a "Type" statement in VBA's class module, I get an error.
> > Is there any way to get around this problem?
[quoted text clipped - 6 lines]
> Type statement can only be used at module level, but aside from that I
> don't see why you might have a problem.
Alex Dybenko - 22 Feb 2005 06:53 GMT
Eddie,
instead of UDF in class modules you can use simple classes
make a class myType
with one property
Public a As Integer
and use it instead of UD type

Signature
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com
> Hi Dirk,
>
[quoted text clipped - 46 lines]
>> Type statement can only be used at module level, but aside from that I
>> don't see why you might have a problem.
Brendan Reynolds - 22 Feb 2005 14:02 GMT
Public user-defined types can only be defined in standard modules, Eddie,
not in class modules (which includes form and report modules).

Signature
Brendan Reynolds (MVP)
> Hi Dirk,
>
[quoted text clipped - 46 lines]
>> Type statement can only be used at module level, but aside from that I
>> don't see why you might have a problem.
eddie' bakery and cafe - 22 Feb 2005 17:27 GMT
Thanks everyone who replied, you feedback was helpful
Regards,
Eddie
> Public user-defined types can only be defined in standard modules, Eddie,
> not in class modules (which includes form and report modules).
[quoted text clipped - 49 lines]
> >> Type statement can only be used at module level, but aside from that I
> >> don't see why you might have a problem.