Saving records

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

Guest

Given the computer skills of the people who will be using my database (myself
included!), I would like to add a procedure that ensures that information
added in a form is not stored until it is physically saved. I have been
searching for information on this, but cannot find it anywhere. What is the
process I am trying to do called, and how do I do it?

Thanks again.
 
Access saves each record, before you enter/visit another record. You cannot
simply make a bunch of changes to disparate records and then decide to save
them all at once.

Many things can trigger the record being saved, e.g. moving to another one,
pressing Shift+Enter, closing the form, appying a filter, changing the sort
order, tabbing past the last control on the form, requerying, ... The only
way to catch them all is to use the BeforeUpdate event of the *form* (not of
a control.) Access fires this event just before saving the record. You can
cancel the event if you don't want the record saved.

Therefore it would be possible to write code behind a "Submit" button, such
that it saves the record, and Form_BeforeUpdate is cancelled if the save
occurs any other way. I'm not sure I could recommend such an approach
though. If the goal is to prevent accidental saves, it might be better to
just include a MsgBox() in Form_BeforeUpdate to confirm the save.
 
Given the computer skills of the people who will be using my database (myself
included!), I would like to add a procedure that ensures that information
added in a form is not stored until it is physically saved. I have been
searching for information on this, but cannot find it anywhere. What is the
process I am trying to do called, and how do I do it?

Thanks again.

This can be fairly simple, or it can be quite difficult indeed. The latter is
the case if you have a Form with one or more Subforms - do you? The problem
there is that Access saves the mainform record to disk the moment you set
focus to any control on the subform.

You can put a Save button on the form, and put code in the form's BeforeUpdate
event to validate the data... in practice, however, putting confirmations and
boxes to check in order to save a record rapidly becomes futile, since users
will just mindlessly check the box or whatever so they can get on with the
job. What would be the downsides of automatic record saving? Can you do some
validation (e.g. this control must be filled in, that control must contain a
date within the past year but not in the future, this other control must
contain a positive number...)? If so, you can use the Form's BeforeUpdate
event to validate and cancel the save if the data is incorrect.

John W. Vinson [MVP]
 
The reason why I want the user to be prompted to save is because when I did a
dummy run, I was finding that the users were doing their monthly stats,
getting distracted, getting back to them, and in some cases, starting the
entry process 4 times for the one job. This information is getting saved
each time this happens, which I don't want to occur, as it affects the level
of work on a particular job. The user is getting as far as the contract
number and entering number of hours worked on that contract, without
completing the allocation of the hours. On this particular form, I want the
information entered and a prompt to save it, otherwise it doesn't get saved.

This particular form does not have a subform, so I think I should be safe
there!

I was thinking of putting a find record, but then the user knows they didn't
complete the form in the first place, so that would be more confusing I
think....
 
I should add that I didn't put any of the job allocations as required fields,
as if they didn't do any field visits, or phone calls then these wouldn't be
filled in. And I couldn't figure out and keep it user friendly, a way of
saying "each of the fields below has to equal the number of hours put in the
top" as invariably they don't. They will often include comments to justify
why they don't (I have a comments field for this)
 
I should add that I didn't put any of the job allocations as required fields,
as if they didn't do any field visits, or phone calls then these wouldn't be
filled in. And I couldn't figure out and keep it user friendly, a way of
saying "each of the fields below has to equal the number of hours put in the
top" as invariably they don't. They will often include comments to justify
why they don't (I have a comments field for this)

Perhaps you could give us some help here! We don't know your business, and we
don't know your database. Could you post the relevant fieldnames (with
datatypes and a brief description of the field's meaning)?

You may be able to make it easier for the user by (say) having the most recent
record appear on the form by default, or by putting a check on some field or
combination of fields so that they can't enter the same data twice.

John W. Vinson [MVP]
 
Back
Top