RecordSet update confusion

  • Thread starter Thread starter MattE
  • Start date Start date
M

MattE

I don't know why it's taking me so long to get the hang of this. I
have a form bound to a table that contains two records. I put in some
simple navigation buttons which work ok. After I've navigated through
to the blank non-existent record at the end, I enter some data for what
should now be record #3 and hit my "Back Out" button which is supposed
to exit the form. But at that point the RecordSet still only has a
RecordCount of 2. And if I do an Update I get an error. What am I
missing?

Thanks in advance!
 
you're missing an update - what do you mean by 'do an update'? how are doing
it?

when you close a form by the convention top/right cross - it updates before
closing the form - your exit method needs to do the same
 
I mean if my "Back Out" button does as its very first thing
Me.Recordset.Update or gets the table that the form is bound to and
does a .Update via that, either way I get "update or cancel without
addnew or edit."

Thanks!
 
You do not need to do the update. Any time you move away from a current
record whether it be by navigation, selecting from a combo, or closing the
form, the current record is updated. Get rid of the "Back Out" button and
you should be okay.
 
try just:

Update

no prefix


I mean if my "Back Out" button does as its very first thing
Me.Recordset.Update or gets the table that the form is bound to and
does a .Update via that, either way I get "update or cancel without
addnew or edit."

Thanks!
 
There is no need for an update.

JethroUK© said:
try just:

Update

no prefix


I mean if my "Back Out" button does as its very first thing
Me.Recordset.Update or gets the table that the form is bound to and
does a .Update via that, either way I get "update or cancel without
addnew or edit."

Thanks!
 
There 'no need' for a close button - there's 'no need' to create your own
record navigation buttons

but maybe he just 'want's to' create his own close button - in which case he
'want's to' save the record before closing the form
 
The form's recordset is being managed by the form so a
simple Update won't do it for you (unless you explicitly
used .Edit or .AddNew

It shouldn't matter how you close the form, if current
record is dirty it should be saved automatically. An
exception to that is if the record fails to save because of
a Validation Rule violation. Either way, you won't be able
to tell if the record was saved until after the form is
closed.

If you feel you want to explicitly save the record at some
point prior to the form closing, use this line of code:

If Me.Dirty Then Me.Dirty = False
 
Your analogies are nonsensical; however, if you want to see how it is done,
see Marshall Barton's post.
 
Thanks for your help, you guys. When I use the red X it seems to work
fine. (If only I'd have tried that much earlier!) If at some point I
wanted to put in my own single control to do the same thing as the red
X, where might I find it?

Thanks again!
Matt
 
The code for your own close button would just be:

DoCmd.Close acForm, Me.Name, acSaveNo
 

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

Back
Top