Connecting Tech Pros Worldwide Help | Site Map

Class in library, no intellisense ?

Arno R
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi,
I am just 'playing' a bit with classes these days. I would like to use a few classes in my
codelibrary. (mde)
I read (and noticed) that you can't use a class directly when the class is referenced and
is not present in the database from where the class is used.
So I Googled a lot on this and found 2 solutions. 1 safe way (documented) and 1 unsafe
(undocumented) way.
The called 'Safe way' is to create a public function in the library to return an instance
of the class.
So I have a class clsMyClass and use a public function like:
Public fclsMyClass () as clsMyClass
set fclsMyClass = New clsMyClass
end function
I reference the codelibrary and in a standard forms_module I use:
Dim mc as Object
Set mc=fclsMyClass
'Do stuff ...
set mc = Nothing
The code works, the properties are there BUT intellisense does NOT work ??
Am I doing something wrong here?

The unsafe way is changing an attibute (VB_Exposed) by exporting/importing.
I also tried the unsafe way (maybe the wrong way ?), and suddenly I had a lot of 'unknown
errors' when opening the vb-project.
BTW, I am using A2k.

Any ideas?
Thanks
Arno R



Stephen K. Young
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Class in library, no intellisense ?


"Arno R" <arracomn_o_s_p_a_m@tiscali.nl> wrote in message
news:422764d1$0$44071$5fc3050@dreader2.news.tiscal i.nl...
....[color=blue]
> I reference the codelibrary and in a standard forms_module I use:
> Dim mc as Object
> Set mc=fclsMyClass
> 'Do stuff ...
> set mc = Nothing
> The code works, the properties are there BUT intellisense does NOT work ??[/color]

For Intellisense to work, you might try declaring "mc" more specifically as:

Dim mc as clsMyClass
Set mc=fclsMyClass

- Steve


Tom van Stiphout
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Class in library, no intellisense ?


On Thu, 3 Mar 2005 20:17:57 +0100, "Arno R"
<arracomn_o_s_p_a_m@tiscali.nl> wrote:

That's by design.
Put yourself in Access' position. Someone declares dim mc as object.
You have no idea what this guy wants, so you give him as little as
possible. You chalk it up as "late binding", and hope for the best.
Now he says set mc=fclsMyClass. You have some options. He may have
made a wrong assignment, like intOne = strTwo. Anyway, you do your
best to provide type coercion, but you still have no clue what the
detailed type of mc might be.
Stephen is right. Give Access what it needs to unambiguously know what
type mc is. Use early binding.

-Tom.


[color=blue]
>Hi,
>I am just 'playing' a bit with classes these days. I would like to use a few classes in my
>codelibrary. (mde)
>I read (and noticed) that you can't use a class directly when the class is referenced and
>is not present in the database from where the class is used.
>So I Googled a lot on this and found 2 solutions. 1 safe way (documented) and 1 unsafe
>(undocumented) way.
>The called 'Safe way' is to create a public function in the library to return an instance
>of the class.
>So I have a class clsMyClass and use a public function like:
>Public fclsMyClass () as clsMyClass
>set fclsMyClass = New clsMyClass
>end function
>I reference the codelibrary and in a standard forms_module I use:
>Dim mc as Object
>Set mc=fclsMyClass
>'Do stuff ...
>set mc = Nothing
>The code works, the properties are there BUT intellisense does NOT work ??
>Am I doing something wrong here?
>
>The unsafe way is changing an attibute (VB_Exposed) by exporting/importing.
>I also tried the unsafe way (maybe the wrong way ?), and suddenly I had a lot of 'unknown
>errors' when opening the vb-project.
>BTW, I am using A2k.
>
>Any ideas?
>Thanks
>Arno R
>
>[/color]

Arno R
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Class in library, no intellisense ?


Thanks, but if I do as you tell me Access protests: "Undefined Object"
The class is in a codelibrary as I wrote.
So I guess I just can't use Intellisense here ...

Arno R

"Stephen K. Young" <s k y @ stanleyassociates . com> schreef in bericht
news:38q4tuF5ps8p0U1@individual.net...[color=blue]
> "Arno R" <arracomn_o_s_p_a_m@tiscali.nl> wrote in message
> news:422764d1$0$44071$5fc3050@dreader2.news.tiscal i.nl...
> ...[color=green]
>> I reference the codelibrary and in a standard forms_module I use:
>> Dim mc as Object
>> Set mc=fclsMyClass
>> 'Do stuff ...
>> set mc = Nothing
>> The code works, the properties are there BUT intellisense does NOT work ??[/color]
>
> For Intellisense to work, you might try declaring "mc" more specifically as:
>
> Dim mc as clsMyClass
> Set mc=fclsMyClass
>
> - Steve
>
>[/color]


Arno R
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Class in library, no intellisense ?


Thanks Tom, but if I do as Stephen tells me Access protests: "Undefined Object"
The class is in a codelibrary as I wrote.
==>> The main issue here is that I can't use early binding.

This just means that when one places class-code in a library one can't use Intellisense.
Never have read that before, but this is just the way it is I guess ...

I will try the undocumented way a bit more and will post back then.

Arno R


"Tom van Stiphout" <no.spam.tom7744@cox.net> schreef in bericht
news:mlsf219460uft65oo5a9idoml5d19bsrrf@4ax.com...[color=blue]
> Stephen is right. Give Access what it needs to unambiguously know what
> type mc is. Use early binding.
>
> -Tom.
>[/color]


Terry Kreft
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Class in library, no intellisense ?


In order to use early binding you need a reference to the library which
contains the object you are trying to bind to.

Therefore in order to use early binding in this case you would have to use
the export the class and change the VB attribute method.

Although you refere to this as the "unsafe" methdo, this isn't really the
case it really should be described as the undocumented method. Just because
it's undocumented does not mean it's unsafe.

In summary; you can export the class, change the attribute and reimport the
class, you then have the choice of using early binding or late binding, with
early binding you will get intellisense halp.

Alternatively you can use a function to return an instance of your class, in
this case you are restricted to using late binding and therefore cannot use
intellisense.


--
Terry Kreft
MVP Microsoft Access


"Arno R" <arracomn_o_s_p_a_m@tiscali.nl> wrote in message
news:42285a7f$0$44084$5fc3050@dreader2.news.tiscal i.nl...[color=blue]
> Thanks, but if I do as you tell me Access protests: "Undefined Object"
> The class is in a codelibrary as I wrote.
> So I guess I just can't use Intellisense here ...
>
> Arno R
>
> "Stephen K. Young" <s k y @ stanleyassociates . com> schreef in bericht
> news:38q4tuF5ps8p0U1@individual.net...[color=green]
> > "Arno R" <arracomn_o_s_p_a_m@tiscali.nl> wrote in message
> > news:422764d1$0$44071$5fc3050@dreader2.news.tiscal i.nl...
> > ...[color=darkred]
> >> I reference the codelibrary and in a standard forms_module I use:
> >> Dim mc as Object
> >> Set mc=fclsMyClass
> >> 'Do stuff ...
> >> set mc = Nothing
> >> The code works, the properties are there BUT intellisense does NOT work[/color][/color][/color]
??[color=blue][color=green]
> >
> > For Intellisense to work, you might try declaring "mc" more specifically[/color][/color]
as:[color=blue][color=green]
> >
> > Dim mc as clsMyClass
> > Set mc=fclsMyClass
> >
> > - Steve
> >
> >[/color]
>
>[/color]


Arno R
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Class in library, no intellisense ?


Hi Terry, thanks for your reply,

"Terry Kreft" <terry.kreft@mps.co.uk> schreef in bericht
news:OvednZqSZYAU9rXfSa8jmA@karoo.co.uk...[color=blue]
> Although you refere to this as the "unsafe" methdo, this isn't really the
> case it really should be described as the undocumented method. Just because
> it's undocumented does not mean it's unsafe.[/color]

Funny, but it is is actually *you* who called this the 'unsafe way' but it is a while
ago... (1999) you must have changed your mind about this ...
It was you I was 'quoting' in my first post on this:
http://groups.google.nl/groups?q=lib...s.co.uk&rnum=2

I wil try the undocumented (hopefully safe) way ... ;-)

Arno R






Closed Thread