473,465 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Save Current Record on a Form

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
2 64447
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tony | last post by:
Hello, I am having difficulty in getting the current record of the current form to show after pressing a command button that takes me to another form. The command button takes me to another...
2
by: dixie | last post by:
I know I've asked this before, but the answer elludes me and the message has long since disappeared from my newsgroup messages. How do you save a record using vba from a button or as part of an...
0
by: Jim Bowe | last post by:
Just converted an Access2000 application from SQL server datbase to a DB2 data base. When I try to edit a current record in a form and click the Save button, I get "No Current Record". I updated...
2
by: Paul Mendez | last post by:
I have a form that consists of 150 records and is still growing. there are times when I want to print a certain record of the form, say record 12. I go to file --> print and choose the page number...
2
by: Rosy | last post by:
I am attempting to use the following code to print a report based on the current record in the form. Users bring up the record with a parameter box and then can make changes to the sub-form on the...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
by: Tom Weston | last post by:
Help I need to save the current record before sending a simple report from it as an email using an event. The following code works for old records but not for the current new one: ------...
5
by: eighthman11 | last post by:
Hi everyone: This is probably a pretty simple problem but it is driving me nuts. Using Access 2000. I have a continuous form which list several thousand inventory items. The user can enter a...
1
by: raddrummer | last post by:
Hi gang, I'm stumped on something that I've been at for a few days and so am seeking help. I'm sending emails to managers to let them know that a performace review is due and attach a custom...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.