Saving records

G

google3luo359

I've Googled many threads on this topic in formscoding and there is a
wealth of information on the subject. However I am still left
scratching my head about a few things.

First off, it seems that the undocumented way of explicitly saving a
record on a form is with the following code:

If Me.Dirty Then Me.Dirty = False

I'd like to understand it. I understand the first part, If Me.Dirty
Why does Me.Dirty = False save the record?
What is the logic behind it? Why does it work?

I have a few forms where, presently, the only saving mechanism I have
is
Do.Cmd Close.
It's working, but then again it's just me on the db. When the db will
be completed there will be 50+ users having the back-end open at the
same time and saving their data at various times.

I want to be sure that I have the best/safest code in place to save
their data.
Should I just leave my Do.Cmd Close to close the form, or use an
explicit save with
If Me.Dirty Then Me.Dirty = False ?

I'm using Access 2000.

TIA Ric
 
D

Douglas J Steele

A form is dirtied (its Dirty property is set to True) when any change is
made to the form.

If the form is dirtied and you try and set its Dirty property back to False,
there are two possibilities: you could undo any changes that were made to
the form so that it's no longer dirty, or you could save the changes so that
it's no longer dirty.

Microsoft chose to take the latter approach.

Explicitly saving the form yourself is always a good idea, even if it isn't
usually necessary. Allen Browne illustrates at least one case where it is
necessary at http://www.allenbrowne.com/bug-01.html
 
G

google3luo359

Friggin Google just ate my reply again !!!!!!
ARGGGGHHHHHHHHHHHHHHH!!!!!!!!!!!!!
Microsoft chose to take the latter approach.

Thanks Doug, now I finally understand it.

Explicitly saving the form yourself is always a good idea, even if it isn't
usually necessary. Allen Browne illustrates at least one case where it is
necessary at http://www.allenbrowne.com/bug-01.html

This is a much shorter version than my first reply from a few minutes
ago..
With 50+ users saving at approx. the same time, using Is Dirty = False
and DoCmd Close
wouldn't there be 100+ saves going on and a greater likelihood for a
fight with the back-end to write the the table?

TIA Ric
 
D

Douglas J. Steele

Friggin Google just ate my reply again !!!!!!
ARGGGGHHHHHHHHHHHHHHH!!!!!!!!!!!!!


Thanks Doug, now I finally understand it.



This is a much shorter version than my first reply from a few minutes
ago..
With 50+ users saving at approx. the same time, using Is Dirty = False
and DoCmd Close
wouldn't there be 100+ saves going on and a greater likelihood for a
fight with the back-end to write the the table?

To be honest, I'm not sure that's going to be the biggest problem you're
going to have with 50+ concurrent users! Access really isn't made to handle
that volume.

However, if you've added Dirty = False, DoCmd.Close shouldn't be performing
a save (unless, of course, you get the form dirty between the two
statements) But what's your alternative? If you've got 50 changes to save,
you've got 50 changes to save!
 
G

google3luo359

Douglas said:
... However, if you've added Dirty = False, DoCmd.Close shouldn't be performing
a save (unless, of course, you get the form dirty between the two
statements)

OK, so DoCmd.Close won't save again if the record was just saved
with Dirty = False.
That's good to know.
But what's your alternative? If you've got 50 changes to save,
you've got 50 changes to save!

Right I know they have to be saved, but I had mistakenly thought
that each one would be saved twice and increasing the chance of a
simultaneous save/write between two users.
I guess I'll just have to cross my fingers and see how things turn out.

Ric
 

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