Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.Save

Status
Not open for further replies.

AnotherGraham

Programmer
Jan 12, 2003
11
0
0
US
How do you save the data in a form without closing the form? I find that DoCmd.Save still leaves the data in the buffer. I have also tried DoCmd.Save AcForm, "frmTheFormIWanttoSave" which transiently worked and then stopped.
My underlying problem is that I wish to add data to a new record in linked form without closing the master form. I cannot however close the second form as the record in the master form
is not known to the system unless the form is closed.
Thanks
Graham
 
HI

I'm no expert but I usually make the form I want to "close" hidden instead so that I can still refer to it. I also requery the data source so that the main form is updated. Does that help?

MoJoP
 
Try this:
[tt]
DoCmd.RunCommand acCmdSaveRecord
[/tt]
The docmd.save command only saves the form object, not the record

Cheers,
Dan
 
Hi MoJop and DanJR, It was really great of you to help in this way. I will go away and try this directly.
Graham

 
I use this extensivly on all of my forms and works all of the time.

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70


:)WB
 
Dan JR
Thanks indeed it worked well. I just cantt see that method listed in any book nor any explanation about the purpose of the DoCmd.Runcommand method.

Graham
 
Hi Wabeg Thanks for your help. I will be trying it. The information about this area is really poor. I think there is another person having the same problem in this forum.
Graham
 
You are most welcome. Hopefully the other person will see this post. How I got the code was pretty simple. I created a on click button using the wizard and chose record and save. It created the coding for me. The Runcommand method I have never seen before so I am using the build in one which works great.

:)WB
 
Hi

I too had the DoCmd.DoMenuItem code come up from the toolbar wizard however, I was advised by another Tek Tipper that the DoCmd.RunCommand method was "cleaner". I'm not experienced enough to know either way....

MoJoP

 
The DoCmd.DoMenuItem is only there for backwards compatability with older versions of Access. The DoCmd.RunCommand, which first appeared in Acc97, now replaces DoCmd.DoMenuItem.

Also, When you convert a database to Access2000, macro's containing DoCmd.DoMenuItem action will be updated to DoCmd.RunCommand. However, occurences in vba code will not be updated.

Thus, DoCmd.RunCommand is the prefered method.

Cheers,
Dan
 
Well I have learned a huge amount thanks everyone for the stimulating conversation.
Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top