testing code from class module

selahlynch

Registered User.
Local time
Today, 14:28
Joined
Jan 3, 2010
Messages
63
1) Are there convenient ways to test code from a class module?

Every time I try to run a procedure from my class module in my immediate window I get an error "Sub or Function not defined"

2) Is it possible to run a procedure from a class module outside of the class module?

I'm imagining something like this:
Forms("CourseAttendance").Module.AClassProcedure()
 
A class is not like a function or sub in standard module. A class needs to be instantiated. So, you need to be able to instantiate the class before you can use any of the objects of the class.

For example, if you have a class called clsStudents, you would need a function or sub in a standard module, form module, or report module to instantiate and then use:

Code:
Dim clSt As clsStudents

Set clSt = New clsStudents

clSt.DoSomethingHere
 
Thanks for the reply.

Say my procedure is in a form module, and this form is currently open. As far as I understand, any form I create is a class, and if it is open it is instantiated.

I still can't run this procedure in the immediate window. Is that normal?
 
I take it back....
It worked, I just had to call the procedure through the form object. Duh!

Forms!CreateSpreadsheet.testprocedure


Thanks.
 

Users who are viewing this thread

Back
Top Bottom