Help!

Immediate Window?

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions RSS
Next:  Posts not appearing  
Author Message
alex
External


Since: Apr 17, 2007
Posts: 23



PostPosted: Wed Oct 28, 2009 6:41 am    Post subject: Immediate Window?
Archived from groups: microsoft>public>access (more info?)

Immediate Window?

Hello,

Using Access ’03…

I’m sure this must be an easy question, but I’m a bit confused.

Why can I run this function in the Immediate Window of a global module
but not in a Class Module.

Function Test()

'Dim db As Database
Dim sql As String
'Set db = CurrentDb()

sql = "select * from table"
Debug.Print sql
'Set ds = db.CreateDynaset(sql)

End Function

In a Global Module - ?Test() will return the sql string.
In a Class Module - ?Test() will return the error: Sub or Function
not defined.

Thanks,
alex
Back to top
alex
External


Since: Apr 17, 2007
Posts: 23



PostPosted: Wed Oct 28, 2009 7:12 am    Post subject: Re: Immediate Window? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Oct 28, 9:47 am, "Dirk Goldgar"
<d... DeleteThis @NOdataSPAMgnostics.com.invalid> wrote:
> A class module has to be instantiated before you can call any of its
> methods.  For example,
>
>     Set o = New clsMyClass : o.Test
>
> --
> Dirk Goldgar, MS Access MVP
> Access tips:www.datagnostics.com/tips.html
>
> (please reply to the newsgroup)
>
> "alex" <sql_... DeleteThis @yahoo.com> wrote in message
>
> news:2ce44c5d-551a-45ae-835c-03e09a3c197b@s15g2000yqs.googlegroups.com...
> Immediate Window?
>
> Hello,
>
> Using Access ’03…
>
> I’m sure this must be an easy question, but I’m a bit confused.
>
> Why can I run this function in the Immediate Window of a global module
> but not in a Class Module.
>
> Function Test()
>
> 'Dim db As Database
> Dim sql As String
> 'Set db = CurrentDb()
>
>          sql = "select * from table"
>          Debug.Print sql
>          'Set ds = db.CreateDynaset(sql)
>
> End Function
>
> In a Global Module - ?Test() will return the sql string.
> In a Class Module - ?Test() will return the error:  Sub or Function
> not defined.
>
> Thanks,
> alex

Thanks Dirk; I think I understand that!
alex
Back to top
Dirk Goldgar
External


Since: Oct 05, 2006
Posts: 65



PostPosted: Wed Oct 28, 2009 9:47 am    Post subject: Re: Immediate Window? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

A class module has to be instantiated before you can call any of its
methods. For example,

Set o = New clsMyClass : o.Test

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

"alex" <sql_aid RemoveThis @yahoo.com> wrote in message
news:2ce44c5d-551a-45ae-835c-03e09a3c197b@s15g2000yqs.googlegroups.com...
Immediate Window?

Hello,

Using Access ’03…

I’m sure this must be an easy question, but I’m a bit confused.

Why can I run this function in the Immediate Window of a global module
but not in a Class Module.

Function Test()

'Dim db As Database
Dim sql As String
'Set db = CurrentDb()

sql = "select * from table"
Debug.Print sql
'Set ds = db.CreateDynaset(sql)

End Function

In a Global Module - ?Test() will return the sql string.
In a Class Module - ?Test() will return the error: Sub or Function
not defined.

Thanks,
alex
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> General Discussions All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum