Change and Save a Record

  • Thread starter Thread starter sara
  • Start date Start date
S

sara

I am new to VBA and forms. I could use some direction
here, if possible.

I have a form and subform. Enter Employee Number and see
all the charge records for that employee. The records
come into us from an outside source. I have a field on
the record "Ignore" which defaults to "NO". If I have to
correct a value on the record, I first change "NO"
to "YES" (so my queries can ignore the 'wrong' record, but
so I don't lose it - in case there's an error somewhere),
and save the original record with "YES", and then change
the value(s) as needed, and save it with Ignore = NO.

I would like the user to choose the record to change from
the sub-form, and be able to save the original record with
Ignore changed to "YES" and the record with the user's
changes with Ignore "No".

I don't know what code to write - I'm not asking for all
the code, just what to do. On what event(s) do I attach
code? What commands do I use? I can do the
DoCmd.DoMenuItem SaveRecord for the change, but I don't
know what code to add - and where to add it - to save the
original record. I also have an "Undo" button, and I want
to make sure it "Undoes" both the new changes and deletes
the record I added for Ignore = Yes.

Thans so much. I am learning, and just need some
guidance - what events, what commands, rather than
detailed code.
Sara
 
Hi,
Not sure why you need a form and a subform ?
See if I have this right -

Display a record where Ignore = 'No'

Write a record that is identical but with Ignore = 'Yes' (so it
doesn't get looked at again but it is on the table just in case)

Allow the user to change one or more fields.

Write the changed record back (not sure if you want No again in case
you need to have another look later - doesn't matter)

Each record needs to be written back in some way so that you can
differentiate them.

So why not just have a single form with all the fields on ?
If a user changes one or more you can have a button that says 'SAVE'
and then prompt for a Yes or No. If Yes then writeor update the
original with Ignore = Yes and then write the changed record. If the
user says 'No' then leave all alone.
It sounds like you are trying to have a min form with the original and
a sub form with the changes ? If you are doing that so that the user
can see the original all the time you could still have a single form
with the orignainl but all fields disabled, with the bottom part of
the form alowing changes. Sam thing as before, if the user changes and
says 'Yes' to a prompt then write/update first and then write the
second. I think if it were me, I'd leave the original file well alone
and write the change to a separate table. That would seem safer from
an audit point of view ?
 
Back
Top