By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,475 Members | 1,372 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,475 IT Pros & Developers. It's quick & easy.

Keeping track of changes in VBA Classes

P: n/a
Hi all,

I'm working on an application in which I already make some
preparations to be able to work in a frontend and backend database,
even if this isn't the issue a this moment. I'm using VBA classes for
this (I know not the easiest way, but I have made some considerations
and I want to to it this way as VBA classes are some new stuff to
explore for me).

In a class 'client' I get the data from the database and put it in
some class variables. I use these variables to fill the textfields of
my unbound form. To avoid to update the database on every view of the
data by a user, I want to keep track of the changes a user made or
didn't make to the data displayed. I any changes were made an update
of the table is done, otherwise not.

I could use an 'afterupdate'-event on every input field on my form,
but I'm wondering if I could do this on a shorter way.

Does anyone has any ideas.

Thanks.

De_Ciise

Feb 27 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
De_Cisse,

You could put the functionality in your classes and set an IsDirty property.
You would of course have to be able to persist the original property values
and see if they are all the same as the updated values.

-- Bill

"De_Cisse" <fr*****************@gmail.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
Hi all,

I'm working on an application in which I already make some
preparations to be able to work in a frontend and backend database,
even if this isn't the issue a this moment. I'm using VBA classes for
this (I know not the easiest way, but I have made some considerations
and I want to to it this way as VBA classes are some new stuff to
explore for me).

In a class 'client' I get the data from the database and put it in
some class variables. I use these variables to fill the textfields of
my unbound form. To avoid to update the database on every view of the
data by a user, I want to keep track of the changes a user made or
didn't make to the data displayed. I any changes were made an update
of the table is done, otherwise not.

I could use an 'afterupdate'-event on every input field on my form,
but I'm wondering if I could do this on a shorter way.

Does anyone has any ideas.

Thanks.

De_Ciise

Feb 27 '07 #2

P: n/a
Well, since you using class object, one of there GREAT features is that you
can multiple instances of that object.

So, right after you load the record, cerate another instance of the object,
and have that load up the same values.

then, your update routine can simply check if any of the values loaded have
changed.....

The problem here becomes that each "property" of a class object in ms-access
is not added to some built in collection.

However, What this means is that I would build the class object with a
"field" collection, and not actually write a separate let/get for each new
field (really, if you have to write new code for each control/field you add
to a form, you going backwards to the stone age in terms of productivity,
and wasted developer time). With a medium sized application having a 160
forms, the maintains nightmare here would be incredible.

Further more, you do realize that form is a class object and all of the
controls etc. that you place on a form are already in a object for you!!!
(so, there is only pain, and wasted developer time if you try and code your
own object when ms-access makes one for you!!). do realize that you can have
multiple instances of the same form in memory? (the reason for this is that
each form is a object). And, you do realize that property get/let code can
be placed into a forms code module (and, functions declared PUBLIC in a
forms module become methods of the form - and, inteli-sense will even work
when you do this!!!).

Using a object to just store data from a form makes very little sense when
that same data is in the form......

However, as you said, you doing this much for learning. So, to simply check
for changes in data, simply as mentioned make a copy of your object right
before you allow edit. When the user is done on the form, check each value
for a difference (this actually what ms-access does internally anyway for
you -- it just that you are coding what is built in).
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
Feb 28 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.