Emailing a report using selected record on form then close form and report

jjake

Registered User.
Local time
Yesterday, 22:46
Joined
Oct 8, 2015
Messages
291
Hi all,

Here is what i have.

A form (Pop up) [frmworkorderrequestnew] to enter data with a submit button

A report [rptnewworkorder] that takes the data from the form (With a query and this in the criteria for workorderid [Forms]![frmWorkOrderRequestNew]![WorkOrderID])

The goal is when the user clicks the submit button it would take the selected record in the form and transfer it to the report. it would then close the form, email the report (from the preview??) then close the preview.

So far i have this...

Code:
Private Sub command531_Click()

Dim strReport As String

strReport = "rptNewWorkOrder"
Me.Refresh
DoCmd.OpenReport strReport, acViewPreview, , "WorkORderid = " & Me!WorkOrderID

DoCmd.SendObject acSendReport, "rptNewWorkOrder", "Format Here", "Email Address Here", , , "Subject Here", "", False

DoCmd.Close acReport, [rptworkorder], acSaveYes


End Sub

Which works great but for some reason i am having trouble closing the darn forms and the report from the preview!! i always get an error or they don't close :banghead:
 
Report name needs to be in quotes, not brackets, or use the variable.
 
What's [rptworkorder] in

Code:
DoCmd.Close acReport, [rptworkorder], acSaveYes

how is it related to "rptNewWorkOrder"

What error are you getting?

How are you closing (or trying to close) the report and form? Close box?
 
Ok i got it. Damn me and my pea brain.

I added this.

Code:
DoCmd.Close acForm, "frmworkorderrequestnew", acSaveYes
DoCmd.Close acReport, "rptNewWorkOrder", acSaveYes
 

Users who are viewing this thread

Back
Top Bottom