Link to home
Start Free TrialLog in
Avatar of cazink
cazinkFlag for United States of America

asked on

Making a new instance of ...

in visual basic one is to make and use what is referred to a 'new instance' of an object. in access we can do the same thing. then we can give that new object properties. as an example: if i make a new employee then give it properties such as fname, lname, bdate, etc. then i believe i have the following: employee.fname, employee.lname, and employee.bdate. apparently this type of object construction is frequent in visual basic. one of the advantages, as i understand it, making changes is easier through out the code. what i am asking in this question is how can i utilize this in access. again i know i can create a new object and the give it properties, but how can i incorporate this into a table and other access objects. is there some teaching on this specific topic.
ASKER CERTIFIED SOLUTION
Avatar of IrogSinta
IrogSinta
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
You might also want to review this: https://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3802-Parent-Class-Builder-Add-In-for-Microsoft-Excel.html

It is an add-in I created for Excel that makes it easier to create class modules, especially when you have classes with "parent" and "child" relationship.  For example, in your case you might have a "parent" class clsEmployees, with members of "child" class clsEmployee.

While it is built for Excel, the add-in can export the code as *.cls files, which you can then import into your Access project.
If you're referring to Objects in VB.NET, then understand that Access doesn't behave the same as .NET. You can build classes and such that work as the other Experts have described, but the environment in Access does not translate over to the environment in .NET.

With that said - you can do quite a lot with classes and such in Access, and you'll find that working with classes in Access is similar to other environments. Access/VBA doesn't support higher-level class methods like Inheritance and such, but it's rare that you truly need those (and if you do, you probably should be working in .NET anyway).
<If you're referring to Objects in VB.NET, then understand that Access doesn't behave the same as .NET. You can build classes and such that work as the other Experts have described, but the environment in Access does not translate over to the environment in .NET.>

Correct, if you are starting out in the .Net world, then this is the way that might be most common
In MS Access, ...not so much...
I have been building Access app for over 10 years and have only done this a few times.
That is not to say that I could not have used one, ...only that I never had a real need.

Can you state your ultimate goal here in terms of what you are trying to accomplish.
(Not terms of the technology)
because this is unclear:
<if i make a new employee then give it properties such as fname, lname, bdate, etc. then i believe i have the following: employee.fname, employee.lname, and employee.bdate. apparently this type of object construction is frequent in visual basic.>
...I am not so sure I understand the context here...
If you want to creates a new employee (In MS Access), this is typically done as a "Record", not as an instance/class.

Since you posted this Q to both the MS Access and .Net Topic areas, you need to tell us what parts of this Q relate to MS Access and what parts pertain to .net.

JeffCoachman