Saving entries immediately in a Subform

J

JohnB

Hi.

I have a problem with a Subform whereby Access thinks
that changes being made by one user are being done by two
Users. What I have is the usual fields bound to a table
and also some command buttons which open other forms
whose fields are bound to the same table. The problem
occurs when users enter details in one of the text
fields, then immediately click on one of the command
buttons and enter data in one of its fields. On trying to
move to a different record, Access brings up a message
saying that another user made changes to the same record
and asking which to save and which to discard. But I
believe it's just getting confused with the same user
making changes to the same table in different ways.

Is there some way I can get access to immediately save
users changes each time they enter data in a field or in
the command buttons form? Does this have to be done for
each field or can it be done once for the whole Subform.

Thanks in advance, JohnB
 
M

Marshall Barton

JohnB said:
I have a problem with a Subform whereby Access thinks
that changes being made by one user are being done by two
Users. What I have is the usual fields bound to a table
and also some command buttons which open other forms
whose fields are bound to the same table. The problem
occurs when users enter details in one of the text
fields, then immediately click on one of the command
buttons and enter data in one of its fields. On trying to
move to a different record, Access brings up a message
saying that another user made changes to the same record
and asking which to save and which to discard. But I
believe it's just getting confused with the same user
making changes to the same table in different ways.

Is there some way I can get access to immediately save
users changes each time they enter data in a field or in
the command buttons form? Does this have to be done for
each field or can it be done once for the whole Subform.


You should do the save in the button, just before the code
that switches to the other form. The other form counts as
another user of the data, not necesssarily a different
person.

Assuming the button is in the same (sub)form as the record
to be saved, the code I prefer to use to force a save is:

If Me.Dirty Then Me.Dirty = False

If the button is in a different form, then replace Me with a
reference to the appropriate form object.
 
J

JohnB

Thank you for the prompt reply, Marsh.

I dont understand how that would force a save but never
mind, it looks as if it will do the job very nicely.

Cheers, JohnB
 
M

Marshall Barton

It does appear to be an arcane incantation ;-)

If a form's current record is dirty (edited), setting the
Dirty property to False has save the record in order to make
the record not dirty.
 
J

JohnB

Thanks for this Marsh. I have added your code to the
command buttons and it works perfectly.

Cheers, JohnB
-----Original Message-----
It does appear to be an arcane incantation ;-)

If a form's current record is dirty (edited), setting the
Dirty property to False has save the record in order to make
the record not dirty.
--
Marsh
MVP [MS Access]


I dont understand how that would force a save but never
mind, it looks as if it will do the job very nicely.

trying
to

.
 

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