By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

Save Current Record on a Form

P: n/a
Ian
I am trying to save the current record on a form before opening a
report, doesn’t sound to hard does it? The code on a buttons on click
event goes like this:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'First save record

I used this for many years with problems using Access 97, when the
database is upgraded to Access 2000 or later I occasionally get an error
message saying “Save Command is not available now”.

I thought this might be because the record is not always dirty, so I
changed the code to:

If Forms!MyFrm.Dirty = True Then
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'First save record
End If

This made no difference and I still got the “Save Command is not
available now”. Error message.

A friend said use this code to save the record:
DoCmd.RunCommand acCmdRefresh 'Save the record

I must admit that this works, always saves the record and never produces
an error message. My question is, what is the correct way to save the
current record? Is the Refresh method a sensible way to attain the
result is there a better method?

Regards
Oct 11 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Ian wrote:
I am trying to save the current record on a form before opening a
report, doesn’t sound to hard does it? The code on a buttons on click
event goes like this:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'First save record

I used this for many years with problems using Access 97, when the
database is upgraded to Access 2000 or later I occasionally get an error
message saying “Save Command is not available now”.

I thought this might be because the record is not always dirty, so I
changed the code to:

If Forms!MyFrm.Dirty = True Then
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'First save record
End If

This made no difference and I still got the “Save Command is not
available now”. Error message.

A friend said use this code to save the record:
DoCmd.RunCommand acCmdRefresh 'Save the record

I must admit that this works, always saves the record and never produces
an error message. My question is, what is the correct way to save the
current record? Is the Refresh method a sensible way to attain the
result is there a better method?

Regards
Allen Browne has some information about this here
http://allenbrowne.com/bug-01.html
discussing different methods, pros and cons...

--
Roy-Vidar
Oct 11 '07 #2

P: n/a
Ian
RoyVidar wrote:
Ian wrote:
>I am trying to save the current record on a form before opening a
report, doesn’t sound to hard does it? The code on a buttons on click
event goes like this:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'First save record

I used this for many years with problems using Access 97, when the
database is upgraded to Access 2000 or later I occasionally get an
error message saying “Save Command is not available now”.

I thought this might be because the record is not always dirty, so I
changed the code to:

If Forms!MyFrm.Dirty = True Then
'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70 'First save record
End If

This made no difference and I still got the “Save Command is not
available now”. Error message.

A friend said use this code to save the record:
DoCmd.RunCommand acCmdRefresh 'Save the record

I must admit that this works, always saves the record and never
produces an error message. My question is, what is the correct way to
save the current record? Is the Refresh method a sensible way to
attain the result is there a better method?

Regards

Allen Browne has some information about this here
http://allenbrowne.com/bug-01.html
discussing different methods, pros and cons...
Thanks very much, this is a very useful link and shows serveral
solutions, very much appreciated.
Oct 11 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.