Update on command

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

Guest

I want to use a form to update a table. Basically, I want the form to act
like a data-entry dialog box. I would enter the data into the form, and
update the table when I click on a command button.

I saw some suggestions on here about using temporary tables. I am very new
at this stuff. Please can anyone point me to some code I could copy?

Many thanks

Vaughan
 
To force a update of the current record data into a table, you can place a
command button on your form (called save).

me.Refresh

It only takes one line of code write out the data.

it is not clear if you rather would have a save prompt ask you when
ms-access tries to save the data..or if you want a save button in addition
to ms-access automatic save feature for you?

I mean, what happens if the user forgets to hit save, and then closes the
form? I am not sure you thought out all the ins, and outs of your approach?

What happens if the user tries to move to the next record, and also does not
hit the save button? (or, perahps you don't have, nor want reocrd navagation
here?)

ms-access will automatically save the data for you, and the one line of code
above will also have ms-access save the data out to a table.

It is just not clear if you "always" want a save prompt?, or are just
looking to add a 'SAVE' buttion to the existing form.
 
I guess you're right. I'm trying to avoid an intermittent error message saing:

"Run time error 3020. Update or CancelUpdate without Addnew or Edit".

My idea was to avoid any update except in controlled circumstances. Maybe
there is a better way to deal with it?

Thanks

Vaughan
 
It is not sure where you are canceling the update...but you add a "check" to
your code to see if the record is "ditry" (been editied).


if me.dirty = false then
' nothing changed...don't undo..or cancel...


And, you can also check for a new record in a form like:

if me.NewReocrd = True then
' this is a new reocrd....

Further, if you have any code that is supposed to "setup" some field
defaults etc, but then if the user does nothing and exits...you don't want a
stray record. Thus, all of your code should be put in the on-insert event.
This event ONLY fires if the user does something...and thus if they just
whack the close button..no blank record is crated..and all your record setup
code does not run.

So, I not sure why you get a internment error..but likely you got some
sequence of events, or some code that not right ....
 
Back
Top