Problem instanciating my newest class module

M

Max Moor

Hi All,

I've started using listviews, and it occurred to me to put some
functions that I'll use regularly in a class module. (ie, FillList,
DeleteCurrentItem, etc.) I'm in Access 2002. I inserted the new class
module, named it MyListView, and declared within it the variable:

Private mobjListViewRef As Object

This is intended to be a reference to the listview for the methods to
operate on. I have properties to go with it:

Public Property Get ListViewRef() As Object
ListViewRef = mobjListViewRef
End Property

Public Property Let ListViewRef(pobjListViewRef As Object)
Set mobjListViewRef = pobjListViewRef
End Property


Now, I have a form with a listview. In it's declaration section I
declared:

Private mobjMyListView As MyListView

In the form's Load event code, I have the lines:

Set mobjMyListView = New MyListView
Set mobjMyListView.ListViewRef = Me!lvContacts.Object

Thanks to Alex for getting me this far. Unfortunately, I still get an
"Object variable or With block variable not set" error on the second of
these lines. It acts like the first, instanciation line isn't working.

As far as I can tell, I do these exact same things setting up another
class module I've put together. Does it have something to do with the
various object reference? Do I have to do something more in the class
module itself? Any other ideas?

Regards,
Max
 
G

George Nicholson

1) Since mobjListViewRef is an Object, you need to use Set, not Let:

Public Property Set ListViewRef(pobjListViewRef As Object)
'(etc)

2) use Set within your Get as well:

Public Property Get ListViewRef() As Object
Set ListViewRef = mobjListViewRef
End Property
 
M

Max Moor

1) Since mobjListViewRef is an Object, you need to use Set, not Let:

Public Property Set ListViewRef(pobjListViewRef As Object)
'(etc)

2) use Set within your Get as well:

Public Property Get ListViewRef() As Object
Set ListViewRef = mobjListViewRef
End Property

Hi George,

I hadn't changed the Let to a Set. Alex showed that, and I missed it.
It's working fine now. Thanks!

Regards,
Max
 
3

3f0ip-4av9

Max Moor said:
Hi All,

I've started using listviews, and it occurred to me to put some >
functions that I'll use regularly in a class module. (ie, FillList,
DeleteCurrentItem, etc.) I'm in Access 2002. I inserted the new class
module, named it MyListView, and declared within it the variable:

Private mobjListViewRef As Object

This is intended to be a reference to the listview for the methods to
operate on. I have properties to go with it:

Public Property Get ListViewRef() As Object
ListViewRef = mobjListViewRef
End Property

Public Property Let ListViewRef(pobjListViewRef As Object)
Set mobjListViewRef = pobjListViewRef
End Property


Now, I have a form with a listview. In it's declaration section I
declared:

Private mobjMyListView As MyListView

In the form's Load event code, I have the lines:

Set mobjMyListView = New MyListView
Set mobjMyListView.ListViewRef = Me!lvContacts.Object

Thanks to Alex for getting me this far. Unfortunately, I still get an
"Object variable or With block variable not set" error on the second of
these lines. It acts like the first, instanciation line isn't working.

As far as I can tell, I do these exact same things setting up another
class module I've put together. Does it have something to do with the
various object reference? Do I have to do something more in the class
module itself? Any other ideas?

Regards,
Max
 

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