Link to home
Start Free TrialLog in
Avatar of Caltor
CaltorFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Does Access 2007 VBA support class inheritance?

Does VBA in Access 2007 support class inheritance? and if so how?
I know how to create a class in a class module but I don't know how to create another class based on the first one.

Eg I have a class called Invoice
I want 4 more classes based upon Invoice called InvoiceA, InvoiceB, InvoiceC, InvoiceD
In other languages I have used such as Visual Foxpro you can do this by specifying
Define Class InvoiceA as Invoice
but I can't see how to do this in Access 2007 VBA.
Is it even possible?

Many thanks
Caltor
SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Caltor

ASKER

Thank you guys

DatabaseMX, by 'there has been no change' I assumed that you meant no. But thank you to graye for clarifiying the answer and making an alternative suggestion. Unfortunately I am too far down the road on this project for a transition from Access to .NET so I will have to use some good old fashioned Select Case statements for now.
Well, one thing I've learned on the site ... never say No unless you are 201% sure.  Since I've only spent a little time with A2007, didn't want to make a blanket statement.  

btw ... don't forget ... Class modules and related functionality
 are very powerful in  VBA.

Thanks for the points ....

mx

Avatar of Caltor

ASKER

Actually I reverted my class back to a function in the end as I couldn't see much of an advantage at all without inheritance. In fact I found that when an error was encoutered in the method/function the debugger pointed me to the calling procedure rather than the actual problematic line in the class method. Seems like the debugger hasn't caught up with class modules yet, Of course I would love to be proved wrong.
Avatar of Greg85374
Greg85374

This is not completely True.  You can do what you asking.  In the class you want to inherit from you put Implements "someclassname" in the declaration section.  In the class you want to use the first class in (your child class) you use SomeClassName_MethodName.  YOu must qualify the parent class procedure with the class name followed by an underscore followed by the procedure name.  Its not true inheritence but it will do what you asked.....
I do not think this is documented but I hope it helps...
Oh, also you must repeat the above steps for every procedure in your parent class or you will get a compile error.
Avatar of Caltor

ASKER

Thanks for the extra info.
I will look into that next time this issue crops up.

PS. I think what I said about the debugger isn't true either. There seems to be an option int eh debugger - tools - options to set whether the debugger breaks in class methods or not.