data save command with fill-out Form

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

Guest

Dear All,

I don't want to save the data's automatically after the Form being filled
out, to be saved after clicking a command button for save, but I don't know
how. I thought it would work if I set up the properties of those fields
with "NO" to the "Allow AutoCorrect". However the data's are still being
recorded.
I read through all the related subjects and also checked this link -

http://www.mvps.org/access/forms/frm0027.htm

Still, I don't know how to work this out. The problem I have is that when
the user forgets to close the window of the form and continue pressing
"Enter", then the data (hours) is doubled. So I want to create a button to
save after entry, not necessary to create any message or just stop the cursor
right after the last field of the form.
Please supply me a simple way to help me resolving this problem.

thanks and appreciate very much,
 
Hi,


To save the modified data, use

Me.Dirty = false


under the Click event (procedure handler ) subroutine for you button.



Hoping it may help,
Vanderghast, Access MVP
 
Thank you for the tip. I tried this out, it didn't work out in the way I
wanted. sorry. I looked into the relevant information of Dirty/On Dirty from
everywhere, but just couldn't figure out how...
Let me explain:
My form is a pop up (Module) form through a click-button, data input only
if required by clicking the button for the form, and I don't want the input
data in the fields of the form to be recorded (saved) in the table until
clicking a command button (save) to save the record after completion of the
form input.

I really hope I can get this worked out, please.....
thanks
 
Hi,


If the form is bound, Me.Dirty=false should save the values actually in
the controls into fields of the table.


When you change the value of a bound control, the VALUE IS NOT SAVED
into the table AT THAT moment. The value is only saved when you change of
record, when you close the form, or when you oblige a record save (through
Me.Dirty=false, or through DoCmd that mimics the User Interface).


Is it that you don't want automatic save when changing of record or closing
the form? if so, have a Boolean variable at the form level, which by
default is false. Then, in the BeforeUpdate event of the FORM, have:

Cancel=BooleanVariable


and, for your Save button, have its click property:


BooleanVariable=true
Me.Dirty=false
BooleanVariable = false


Doing so, your record won't be saved unless your user click the said button.



Hoping it may help,
Vanderghast, Access MVP
 
Thanks Michel.
I tried this out. It's really simple and good for me, but it still saved
automatically. even though I didn't click the save button. What did I miss?
Did I miss what you'r saying: "...have a Boolean variable at the form
level,....
what do you mean by this? My form (single form) was created from the table.

please explain. appreciate your patience.
 
Hi,


Right after the

==========================
Option Compare Database
Option Explicit
==========================

add

===========================
Private BooleanVariable As Boolean
===========================



before any other executable code, of your form used as dialog, in its VBA
code.




Hoping it may help,
Vanderghast, Access MVP
 
Hi, Michel, I am sorry to bother you again.
I did what you said.
When I clicked the save button, I got the following error msg:
Run time error '2101'
The setting you entered isn't valid for this property.
Then I checked the Debug msg: (highlighted) Me.Dirty=False

what shall I do now?
 
Hi,


Your form is bound or unbound? An unbound form cannot be dirty, or not
dirty.

It seems you have an unbound form. If the form is unbound, exiting it
won't save any data anywhere, automatically. You have to explicitly save it
through an update or an append statement. Your exact context is more and
more obscure to me. I would assume you want to append a new record, so
something like:


DoCmd.Execute "INSERT INTO tableName ( field1, field2) VALUES
(FORMS!formName!Control1, FORMS!FormName!Control2) ", dbFailOnError


would try to insert a new record into tableName, with the actual value in
FORMS!formName!Control1 under the column field1, and the actual value of
FORMS!formName!Control2 into field2. I would use that statement, for an
UNBOUND FORM, instead of Me.Dirty=false, which is only valid for a bound
form.


If you want to update an existing record instead, use an UPDATE statement,
with a WHERE clause specifying THE record to be updated.




Vanderghast, Access MVP
 
okay, thanks, I am sorry for all the troubles. My form is a bound one, but
now you give me an idea to create an unbound one to insert into the table
instead.... thanks for the tip. yes, this is really good tip - I will go for
unbound one now....hope this will work out what I wanted.
thanks for all your time involved.
best regards,
karen
 
Back
Top