473,379 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 64425
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.