Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old February 27th, 2007, 09:25 PM
De_Cisse
Guest
 
Posts: n/a
Default Keeping track of changes in VBA Classes

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

  #2  
Old February 27th, 2007, 10:15 PM
AlterEgo
Guest
 
Posts: n/a
Default Re: Keeping track of changes in VBA Classes

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" <francisdebrabandere@gmail.comwrote in message
news:1172611150.674344.311070@s48g2000cws.googlegr oups.com...
Quote:
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
>

  #3  
Old February 28th, 2007, 02:35 PM
Albert D. Kallal
Guest
 
Posts: n/a
Default Re: Keeping track of changes in VBA Classes

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
pleaseNOOSpamKallal@msn.com


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles