Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access VBA OOP Implements method not executing

Status
Not open for further replies.

papadilbert

Programmer
Sep 24, 2004
23
US
I coded a simple example of a base class and child class. The base class has one filed and the Let and Get "dummy" properties to maintain it. The implementation of the Let and Get properties are coded in the child class.

The problem is that the child properties are not being executed. Instead, the parent properties are executed.

Here is more detail



I have a base class "clsSimple" that defines Private CustomerName as String.

In the base class I coded (abbreviated below):

Private Property Get CustomerName()
'empty
end Property

Private Property Let CustomerName()
'empty
end Property

----------------------

The child class is an Access form with a button.

In the child class I coded (abbreviated):

'----- aForm--------------

Implements clsSimple

Private Property Get clsSimple_CustomerName()
...code...
End Property

Private Property Let clsSimple_CustomerName()
...code...
End Property


Private Sub aButton_Click()
Dim objSim As clsSimple
Set objSim = New clsSimple

objSim.CustomerName = "George"

Set objSim = Nothing

End Sub

-------------

My expectation was that when aButton_Click() is executed, the statement objSim.CustomerName = "George" would execute the Set property of the child class, it being the implementation of the parent property.

Instead, the Set property of the base class is being executed.

Where have I gone wrong?



 
Basic idea of what's wrong is that you're not making a reference to the class that implements clsSimple at all. You're instantiating the clsSimple class and assigning it values directly.

Have a go with:
Code:
Set objSim = New aForm
Step through it and see the properties being set in the class implementing clsSimple.

Hope this helps, if you'd like any further information about what's happening with the implementation don't hesitate to ask.

Hope this helps

Andy
---------------------------------
Zebracorn: 50% Zebra, 50% Unicorn = 100% Real.

 
That is it exactly. I created an instance of the wrong class. DUH.
Thanks for the response!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top