Immediate Window?

A

alex

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
 
D

Dirk Goldgar

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)

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
 
A

alex

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)


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
 

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

Similar Threads


Top