On Open Event

J

Joyce O

In my database I have a field for "CaseType". I have many
reports and forms that reference this field and all is
working great. Recently we have noticed that
the "CaseType" entered is many times incorrect and needs
to be revised. I'm all set with updating my table with
the new revised CaseType, but here is where I have a
problem. I would like to keep track of
the "PreviousCaseType" for training purposes. How can I
get Access to automatically move "CaseType" to
the "PreviousCaseType" field when my Revise Case Form is
launched (I only want the field of "PreviousCaseType" to
populate when the case type is actually revised). My
thoughts were that I could use code to accomplish this on
the On Open property, but I'm not sure how to write the
code. Any help you can give is appriciated, thank you
 
W

Wayne Morgan

How many revisions do you want to track? If it is just the last one and you
are using a form, then in the form's BeforeUpdate event, set
PreviousCaseType to the OldValue property of CaseType. You would need to
verify that the OldValue property actually contains a value before assigning
it since that may no be the reason the form is updating (another field may
have been changed). This could also be done in the AfterUpdate event of
CaseType, but you'd have to remember to Undo it if the change to CaseType
was undone.
 
J

Joyce O

We actually will be updating dozens of cases a day. I
want to retain both values, CaseType and PreviousCaseType
in my table. Can I do this with code, I'm just not sure.
Thanks
 
W

Wayne Morgan

By "how many revisions do you want to track", I wasn't asking how many a day
you were going to do, but how many changes to EACH record you were wanting
to track. Your present description sounds as if you just want to keep the
last change for each record.

Yes, this can be done through code as mentioned in the previous post.

Example:
'In the form's BeforeUpdate event
If Me.txtCaseType.Value <> Me.txtCaseType.OldValue Then
Me.txtPreviousCaseType = Me.txtCaseType.OldValue
End If
 

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

Similar Threads


Top