Collections and IDs (Access and VBA)

B

ByB

Hello,

I am developping an app in VBA with Access. I work mainly with class
modules and OOP.
My problem is as follow :

- I created a class A. This class as a collection of 0 to 5 objects of
class B.
- I created the class B and it also has a collection of 0 to N objects
of class C.
- I created the class C.

So I have 1 object from class A, with 0 to 5 objects of class B in a
collection. Each object of class B has 0 to N objects iof class C in a
collection too.

The objects ou class C come from a database. So they have already an ID
I can use as the key when adding them to the collection of class B
objects.

But the objects of class B don't come from a database. I create them
myself in the app. So my concern is : what key should I use to identify
them and store them into (and retrieve them from) the collection in the
class A object ? Is it a good idea to use date and time of creation ?

So in fact, my main concern is how to create a unique ID from VBA code
to use the ID as a key when adding them into the collection, and how to
keep the ID (or recalculate it) when looking for retrieving the object
from the same collection ?

Thank you.
 
C

Cindy M.

Hi ByB,

Have you been able to solve this to your satisfaction? If not, you may
want to try asking in the access programming newsgroup, or in a classic VB
newsgroup (most things you learn there can be transferred to VBA).
I am developping an app in VBA with Access. I work mainly with class
modules and OOP.
My problem is as follow :

- I created a class A. This class as a collection of 0 to 5 objects of
class B.
- I created the class B and it also has a collection of 0 to N objects
of class C.
- I created the class C.

So I have 1 object from class A, with 0 to 5 objects of class B in a
collection. Each object of class B has 0 to N objects iof class C in a
collection too.

The objects ou class C come from a database. So they have already an ID
I can use as the key when adding them to the collection of class B
objects.

But the objects of class B don't come from a database. I create them
myself in the app. So my concern is : what key should I use to identify
them and store them into (and retrieve them from) the collection in the
class A object ? Is it a good idea to use date and time of creation ?

So in fact, my main concern is how to create a unique ID from VBA code
to use the ID as a key when adding them into the collection, and how to
keep the ID (or recalculate it) when looking for retrieving the object
from the same collection ?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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