Creating history record

L

Larry T.

I have a form that allows the user to update a record. I have used a command
button to perform this function. Now the user wants the before image to be
saved to another table for history. I have saved all fields prior to any
changes. The problem I now have is using that save information to update the
history data base. I would like to have it all done using the save command
button. In other words;
save updated record, than save history record using before images.
Thanks for any help.
 
S

Steve Schapel

Larry,

You can use an Append Query to put a copy of the existing record into
the history table. I guess it would seem logical to me to do this prior
to editing?
 
L

leturner

Steve,
I will give this a shot.
The reason I need to wait until they hit the save command is that they have
an undo key if can they change their minds during the update. They could hit
either key. No update, no history.
I'll let you know how things turn out.

Thanks
 
L

leturner

Steve, Tina

Took your advice, everything fell into place.

Thanks to both of you.

Larry
--
leturner


tina said:
well, until the current record in the form is written to the table, what
you'll see in the form is the edited data, but what's stored in the table is
still the "old" data. try writing an Append query that pulls the data
directly from the data table into the history table; set a criteria on the
primary key field to pull that value from the form, as

WHERE MyFieldName = [Forms]![MyFormName]![MyFieldName]

substitute the correct form name and primary key field name, of course. in
the macro on the Save button, use the Actions in the following order:

SetWarnings (On = No or False)
OpenQuery (run the Append query)
SetWarnings (On = Yes or True)
SaveRecord (save the current record in the form)

if you use the Save button to save *new* records, as well as saving changes
to existing records, you MAY get an error on the OpenQuery action (i haven't
tested this solution, so can't say for sure). if you do, post back and we
can probably fix it.

hth
 
T

tina

you're welcome :)


leturner said:
Steve, Tina

Took your advice, everything fell into place.

Thanks to both of you.

Larry
--
leturner


tina said:
well, until the current record in the form is written to the table, what
you'll see in the form is the edited data, but what's stored in the table is
still the "old" data. try writing an Append query that pulls the data
directly from the data table into the history table; set a criteria on the
primary key field to pull that value from the form, as

WHERE MyFieldName = [Forms]![MyFormName]![MyFieldName]

substitute the correct form name and primary key field name, of course. in
the macro on the Save button, use the Actions in the following order:

SetWarnings (On = No or False)
OpenQuery (run the Append query)
SetWarnings (On = Yes or True)
SaveRecord (save the current record in the form)

if you use the Save button to save *new* records, as well as saving changes
to existing records, you MAY get an error on the OpenQuery action (i haven't
tested this solution, so can't say for sure). if you do, post back and we
can probably fix it.

hth


leturner said:
Steve,
I will give this a shot.
The reason I need to wait until they hit the save command is that they have
an undo key if can they change their minds during the update. They
could
hit
either key. No update, no history.
I'll let you know how things turn out.

Thanks
--
leturner


:

Larry,

You can use an Append Query to put a copy of the existing record into
the history table. I guess it would seem logical to me to do this prior
to editing?

--
Steve Schapel, Microsoft Access MVP


Larry T. wrote:
I have a form that allows the user to update a record. I have
used a
command
button to perform this function. Now the user wants the before
image
to be
saved to another table for history. I have saved all fields prior
to
any
changes. The problem I now have is using that save information to update the
history data base. I would like to have it all done using the save command
button. In other words;
save updated record, than save history record using before images.
Thanks for any help.
 

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