custom class module

G

Guest

Hello,
I have built a very small and easy class module for a questionnaire we cal
"Abs".
I have called the class Abs. Here is the
Code:
 (there is something more but
similar):

[Option Compare Database
Private question As String
Private prequestion As String

Public Property Get avviso() As String
'ricevo l'avviso che precede la domanda
avviso = prequestion
End Property

Public Property Let avviso(i As String)
'stabilisco l'avviso che precede la domanda
prequestion = carica_caption(i)
End Property]


I'm having trouble instanciating it. i mean: I cannot instanciate it at all!!
Once I digit ---> [dim questionnaire as Abs]  I get this error message :
----
compile error:
Expected: New or type Name
-------
Even if i digit ---> [dim questionnaire as New Abs]   I get the msg:
compile error:
Expected: identifier

Why?
I can see my Abs object in the Object Browser but cannot instanciate it...
Ok, this is my first experience with custom classes after lots of reading. I
was expecting troubles... but not so soon!!!!!!!!!!!!!!
 
B

Brendan Reynolds

'Abs' is the name of a built-in VBA function. You could either
'disambiguate' by specifying your project name in the declaration ...

Dim questionnaire As YourProjectName.Abs

.... or rename your class.
 
G

Guest

I had posted this question, and was waiting for a response- since it's
similar to the one below (and doesn't use a keyword like 'ABS') I thought you
might have some insight:

Regarding the reply below, I have seen the VB_Creatable/Exposed Attributes,
and I think I was able to modify one or both, making them visible in the OB;
I used a nice utility that exports the class as text, changed the attribute,
and re-imported the class. I believe that this would be ok, and probably
could be automated to update the 200 or so classes that I would need to
change. I have seen this done in another example, but I had lost everthing
in hurricane Katrina (lived in New Orleans), and was not able to ask how it
was being done before the disaster- but I know it works (this was in and
Access '97 DB- I would like to do this same process for 200-2003 version as
well).

However, with that said, I really am searching for a function that will
instantiate required classes on load, and a similar one to release them if
they are not needed, or upon close. Right now, these are basically shared
classes, and functions in modules, that are in a separate MS Access DB. If
you know of a link for such functions, I would appreciate it. Also, is there
any advantage putting them in a library file instead of an .mdb, and would it
eliminate all of the above issues?

Thanks for any help! Steve

'69 Camaro said:
Hi, Steve.

The class's VB_Exposed attribute allows other databases to see the class,
and the VB_Creatable attribute allows other databases to instantiate objects
from the class. Depending upon which version of Access you are using, even
if you change the VB_Exposed attribute to allow you to see the class from
other databases, you may not be able to change the VB_Creatable attribute, so
won't be able to instantiate the object in another database.

Please see the following Web page for a discussion last year about the pros
and cons of several different approaches to the problem:

http://groups.google.com/group/micr...*+author:camaro&rnum=1&hl=en#fac51736f3c70e61

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.

Brendan Reynolds said:
'Abs' is the name of a built-in VBA function. You could either
'disambiguate' by specifying your project name in the declaration ...

Dim questionnaire As YourProjectName.Abs

.... or rename your class.

--
Brendan Reynolds

rocco said:
Hello,
I have built a very small and easy class module for a questionnaire we cal
"Abs".
I have called the class Abs. Here is the
Code:
 (there is something more
but
similar):

[Option Compare Database
Private question As String
Private prequestion As String

Public Property Get avviso() As String
'ricevo l'avviso che precede la domanda
avviso = prequestion
End Property

Public Property Let avviso(i As String)
'stabilisco l'avviso che precede la domanda
prequestion = carica_caption(i)
End Property]


I'm having trouble instanciating it. i mean: I cannot instanciate it at
all!!
Once I digit ---> [dim questionnaire as Abs]  I get this error message :
----
compile error:
Expected: New or type Name
-------
Even if i digit ---> [dim questionnaire as New Abs]   I get the msg:
compile error:
Expected: identifier

Why?
I can see my Abs object in the Object Browser but cannot instanciate it...
Ok, this is my first experience with custom classes after lots of reading.
I
was expecting troubles... but not so soon!!!!!!!!!!!!!![/QUOTE]
[/QUOTE]
 

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