Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / February 2005

Tip: Looking for answers? Try searching our database.

Problem using "Type" in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eddie's Bakery and Cafe' - 22 Feb 2005 02:05 GMT
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
Dirk Goldgar - 22 Feb 2005 03:21 GMT
> 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

Where are you using the statement?  What error are you getting?  The
Type statement can only be used at module level, but aside from that I
don't see why you might have a problem.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Eddie's Bakery and Cafe' - 22 Feb 2005 06:01 GMT
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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.