Hello,
I'd like send access report via email.
Now I'm printing my report. I use command button on access form. My code for printing:
Private Sub Command119_Click()
On Error GoTo Err_Command119_Click
Dim stDocName As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
If Me.Combo97 = "Collect" Then
If IsNull(Me.Collect_Acct__) Then
MsgBox "If specifying collect, you must enter an account number"
Exit Sub
End If
End If
If IsNull(Me.Division) Then
MsgBox "You must enter a division"
Exit Sub
End If
If IsNull(Me.CompanyName) Then
MsgBox "You must enter a company name"
Exit Sub
End If
If IsNull(Me.Date) Then
MsgBox "You must enter a date"
Exit Sub
End If
If IsNull(Me.ContactFirstName
) Then
MsgBox "You must enter a contact first name"
Exit Sub
End If
If IsNull(Me.ContactLastName)
Then
MsgBox "You must enter a contact last name"
Exit Sub
End If
If IsNull(Me.BillingAddress) Then
MsgBox "You must enter a billing address"
Exit Sub
End If
If IsNull(Me.City) Then
MsgBox "You must enter a city"
Exit Sub
End If
If IsNull(Me.StateOrProvince)
Then
MsgBox "You must enter a state"
Exit Sub
End If
If IsNull(Me.PostalCode) Then
MsgBox "You must enter a Zip"
Exit Sub
End If
If Me.Division = "FASTEX" Then
stDocName = "Letter-Fastex"
Else
stDocName = "Letter-test1"
End If
'DoCmd.OpenReport stDocName, acPreview, , "customerid= " + Str$(Me.CustomerID)
DoCmd.OpenReport stDocName, acNormal, , "customerid= " + Str$(Me.CustomerID)
Exit_Command119_Click:
Exit Sub
Err_Command119_Click:
MsgBox Err.Description
Resume Exit_Command119_Click
End Sub
Source for report (query):
SELECT Customers.*, [Sales People].*, Distributors.*, Distributors_1.*
FROM ((Customers LEFT JOIN [Sales People] ON Customers.SalesID = [Sales People].SalesID) LEFT JOIN Distributors ON Customers.DistributorID = Distributors.DistributorID
) LEFT JOIN Distributors AS Distributors_1 ON Customers.DistributorID2 = Distributors_1.Distributor
ID;
What I need ?
1.send report over email base on criteria from 1'st code.
How can I prepare code?
I used DoCmd.SendObject for this but send me all records. I don't want this way. I want send only one record (this record what I have open right now in my form)
2. I have table distributors and 2 fields inside (Email and Email1)
I'd like use somehow these fields.
I mean when send report use field Email as TO and Email1 as CC.
thx
henry
Start Free Trial