what's wrong with my declaration?

G

Guest

Hello,
I have a class module and at module level I have declared a custum data
type. This is the code:
Option Compare Database
Option Explicit

Public Type valutatore
codrater As Integer
lastname As String * 50
ratername As String * 50
End Type

This code will not work because it says i cannot define a Public
user-defined type within an object module. I have thus added the 'Private'
and it works.

My question is why it will not work since in the help it is written: <<In
standard modules and class modules, user-defined types are public by
default.>>
So I understood that I can use 'Public' (but compiling gives me the error
reported).

All this mess is because I want to have the variable declared of my
user-defined type to be accessible also from other modules in the project.
But the help says that...<<you can declare a variable of that type anywhere
within the scope of the declaration...>>. So I guess that I can only go
'Private'.

So, since I'm almost sure it is me...what I missed to understand the right
way?

Thanks!
Rocco
 
D

Douglas J. Steele

Looks as though an error may have crept into the Help file (gasp! <g>)

According to Help in Access 97, "In standard modules, user-defined types are
public by default. This visibility can be changed using the Private keyword.
In class modules, however, user-defined types can only be private and the
visibility can't be changed using the Public keyword."
 
M

Marshall Barton

rocco said:
I have a class module and at module level I have declared a custum data
type. This is the code:
Option Compare Database
Option Explicit

Public Type valutatore
codrater As Integer
lastname As String * 50
ratername As String * 50
End Type

This code will not work because it says i cannot define a Public
user-defined type within an object module. I have thus added the 'Private'
and it works.

My question is why it will not work since in the help it is written: <<In
standard modules and class modules, user-defined types are public by
default.>>
So I understood that I can use 'Public' (but compiling gives me the error
reported).

All this mess is because I want to have the variable declared of my
user-defined type to be accessible also from other modules in the project.
But the help says that...<<you can declare a variable of that type anywhere
within the scope of the declaration...>>. So I guess that I can only go
'Private'.


Help is not perfect, so what else is new :-(

Just create a companion standard module to hold your Public
Type declaration.
 

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