Alternative to acCmdSave

T

Tom Ventouris

I am using the code below, on a command button on an inpout form based on a
query from three four tables. The purpose of the button is to create a Table
to which I have merged a Word Document for E Mail.
I inserted the first line to save the current record thus ensuring that it
is included in the new table.

The Save Process seems to be locking the database just as the Word document
is opening to merge with the data. (I get a message warning that the DB is
locked by...") - it works as expected when I remove the save command from
the code, but I have hundreds of records to merge and need to be sure that
the latest or current record is included.

I am looking for an alternative method to "commit" the current record, or
some other way to ensure that all records are included in my query.

Any advice?

*********Code begins**********
DoCmd.RunCommand acCmdSave
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryWelcomeMessage"
Dim MailPath As String
MailPath = CurrentProject.Path & "\" & "mailTemplates" & "\" &
"WelcomeMessage.docx"
Application.FollowHyperlink MailPath
DoCmd.SetWarnings True
*******Code Ends************
 
J

John W. Vinson

I am using the code below, on a command button on an inpout form based on a
query from three four tables. The purpose of the button is to create a Table
to which I have merged a Word Document for E Mail.
I inserted the first line to save the current record thus ensuring that it
is included in the new table.

The Save Process seems to be locking the database just as the Word document
is opening to merge with the data. (I get a message warning that the DB is
locked by...") - it works as expected when I remove the save command from
the code, but I have hundreds of records to merge and need to be sure that
the latest or current record is included.

I am looking for an alternative method to "commit" the current record, or
some other way to ensure that all records are included in my query.

Any advice?

*********Code begins**********
DoCmd.RunCommand acCmdSave
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryWelcomeMessage"
Dim MailPath As String
MailPath = CurrentProject.Path & "\" & "mailTemplates" & "\" &
"WelcomeMessage.docx"
Application.FollowHyperlink MailPath
DoCmd.SetWarnings True
*******Code Ends************

acCmdSave saves *design changes to the structure of the object* - your Form,
typically. It doesn't save the record!

Instead use either

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False
 
T

Tom Ventouris

Thank you.

The save record command does it.

John W. Vinson said:
acCmdSave saves *design changes to the structure of the object* - your
Form,
typically. It doesn't save the record!

Instead use either

DoCmd.RunCommand acCmdSaveRecord

or

If Me.Dirty Then Me.Dirty = False
 

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

Top