Continuous form - distinguishing between records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a continuous form displaying anywhere from 1 to 5 records at a time.
The user is allowed to edit the contents of some of the fields of each
record. Let's say there are 2 records displayed and the user changes the
contents of Field A for both records as follows:

Record 1, Field A original value = 4250 *
Record 2, Field A original value = 3320

Record 1, Field A user-edited value = 5425
Record 2, Field A user-edited value = 4250 *

My code compares the original value for Field A to the edited value to see
if in fact the user made a change. But the code can't distinguish between
Record 1 and Record 2 of this continuous form, so in this example it thinks
no change has been made by the user when in fact it has.

Somehow, I have to be able to programmatically determine which record the
user is modifying. Unfortunately, with this data table there is no way to
take a combination of the fields to create an unquestionably unique
identifier field for each record.

Any ideas on how my code can distinguish between records without a unique
identifier field?

ctdak
 
ctdak said:
I have a continuous form displaying anywhere from 1 to 5 records at a time.
The user is allowed to edit the contents of some of the fields of each
record. Let's say there are 2 records displayed and the user changes the
contents of Field A for both records as follows:

Record 1, Field A original value = 4250 *
Record 2, Field A original value = 3320

Record 1, Field A user-edited value = 5425
Record 2, Field A user-edited value = 4250 *

My code compares the original value for Field A to the edited value to see
if in fact the user made a change. But the code can't distinguish between
Record 1 and Record 2 of this continuous form, so in this example it thinks
no change has been made by the user when in fact it has.

Somehow, I have to be able to programmatically determine which record the
user is modifying. Unfortunately, with this data table there is no way to
take a combination of the fields to create an unquestionably unique
identifier field for each record.

Any ideas on how my code can distinguish between records without a unique
identifier field?


Access creates a unique identifyer for each record in a
recordset, including a form's data. Check in Help for the
Bookmark property.

That may not be what you're really looking for though. If
the form and the field are bound, you can check each record
for being changed in the form's Dirty, BeforeUpdate or
AfterUpdate events, depending on what you're trying to
accomplish.

If you want to do something like log each edit to each
record, I think you should use each control's After update
event.
 
My code compares the original value for Field A to the edited value to see
if in fact the user made a change. But the code can't distinguish between
Record 1 and Record 2 of this continuous form, so in this example it thinks
no change has been made by the user when in fact it has.

Just to add to Marshall's remarks: Each record on the Subform is saved
to disk the moment you move off it, or set focus back to the mainform.
As far as the mainform is concerned, there *are* no "active" records
on the subform, and there are no "changed" records; they have already
been saved to disk by the time the mainform code gets involved, and
are at this point "old records".

You may want to be putting code into the *subform's* Before or
AfterUpdate events to trap changes (one record at a time) to the
subform's recordsource. The mainform's Before and After Update events
will not work for you in the way you may be thinking.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
March,

Thanks for your response. I think you guessed right that a bookmark will
not do what I need. After mulling over your suggestions, I have come to the
conclusion that I probably need to add a field to my table that will make
each record unique, and then use this as the way to test values before and
after the user does his editing. Otherwise I can't trap the case where a
user edits a record more than once and ends up returning it to its original
values, which I need to be able to treat as a non-change.

ctdak
 
John,

Thanks for the additional input. I didn't refer to a main form/subform
context, however it so happens that this is the context, so your comments are
pertinent.

Yes, I need to check the subform one record at a time. However, this still
doesn't cut it. What if the user makes a change to only one displayed record
and then goes back to that record before leaving and undoes the change by
putting the data back as it was. My requirement is to consider this a
non-change, as if the user had done nothing.

Maybe I need to be able to save the beginning values of all fields of each
displayed record, then compare those with the ending values when the user is
done. This seems tricky, if not impossible, using a continuous form. The
alternative seems to be to have a unique data field to use in the
record-by-record testing of before and after values. The latter is what I am
now considering.

ctdak
 
What if the user makes a change to only one displayed record
and then goes back to that record before leaving and undoes the change by
putting the data back as it was. My requirement is to consider this a
non-change, as if the user had done nothing.

You're right. You'll need to save the "before" records to a different
table and compare. The problem is that *you* see the Form with a
Subform full of data as one "thing"; Access sees it as many "things",
one record for the mainform and multiple independent records for the
subform. So you need to save this whole "thing" somewhere!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Thanks for the confirmation.
ctdak


John Vinson said:
You're right. You'll need to save the "before" records to a different
table and compare. The problem is that *you* see the Form with a
Subform full of data as one "thing"; Access sees it as many "things",
one record for the mainform and multiple independent records for the
subform. So you need to save this whole "thing" somewhere!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top