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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Over use of the DoCmd

Status
Not open for further replies.

fvigors

IS-IT--Management
Aug 1, 2001
1
IE
Hi,
I have created a command button on one of my forms, When the button is pressed, it does the following,
Asks the question do "Do you wish to approve the scheme"
When I select yes, it generates a report, and then prints pages 1 and 2 and another copy of page 1, it then closes the report and returns to the original form.

The following piece of code does work,
However my question is this. Is it necessary to have the DoCmd on so many lines or is it more efficient, code wise to combine the command.

If it is more efficient to combine the code please let me know.

Thanking you in advance

Private Sub btnApproveScheme_Click()
Dim Msg, Style, Title, Response, MyString
Msg = "Do you wish to approve this scheme" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "approve Local Authorities Request" ' Define title.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Forms!frmSchemeDetails!DateApp = Now()
Forms!frmSchemeDetails![Letter Printed] = True
DoCmd.OpenReport "rptApprovalLetter", acViewPreview, "", ""
DoCmd.PrintOut acPages, 1, 2, acHigh, 1, True
DoCmd.PrintOut acPages, 1, 1, acHigh, 1, True
DoCmd.Close acReport, "rptApprovalLetter", acSaveNo
DoCmd.Maximize
Else ' User chose No.
MyString = "No" ' Perform some action.
DoCmd.CancelEvent
End If
End Sub
 
No I think it's a lot cleaner thanks very much.

Forbes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top