Displaying specific details in a report

benjee

Personal Jesus
Local time
Today, 05:30
Joined
Mar 19, 2003
Messages
53
Hello and happy easter!

Have a reports menu, and one of the options when clicked displays all invoices for every customer (in a report).

When this particular button is clicked is it possible for some kind of list box to appear, displaying customers names, so i don't have to remember them each time.

Thus enabling a specific invoice to appear for the selected customer.
 
Pat code works on the preview but not the print option.

Here is my amended code: -

Private Sub Command3_Click()

On Error GoTo Err_Command3_Click

Dim strDocName As String
Dim PrintMode As Integer
Dim strWhere As String

strWhere = ""

If Me.fraprintoption = 2 Then
PrintMode = acNormal
Else
PrintMode = acPreview
End If

Select Case Me.fraprintoption
Case 1
strWhere = "[Surname] = """ & Me.[Combo0] & """"
strDocName = "rptInvoice"
DoCmd.PrintOut "rptInvoice", acPreview, PrintMode
Case Else
MsgBox "Please select a report", vbOKOnly
Exit Sub
End Select

If IsNull(Me.Combo0) Then
DoCmd.OpenReport strDocName, PrintMode
Else
DoCmd.OpenReport strDocName, PrintMode, , strWhere
End If

Exit_Command3_Click:
Exit Sub

Err_Command3_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_Command3_Click

End Sub

If you view the image you should see what im trying to do. Basically i want to print all reports via customer, rather than selecting the report name
 

Attachments

  • frmlink.jpg
    frmlink.jpg
    18.6 KB · Views: 195
Last edited:
Pat once again thanks for your post -- most helpful.

But regarding your 'meaningful name' remark, for the purposes of this example i understand what those control names relate to and i intend to change the questionable control names when i release my product for beta testing.

regards
 
Hello,

I was going to provide a scarcastic answer then, but his is nor the time or the place.

Yes, i will remember each reference ive made.

thanks.
 
For what possible reason would a genuine question be worthy of a sarcastic response, no worries, we now know how to deal with your questions
 
Hello, in response to Pats post about previewing or printing a report is there a way to email a customer with their specfic invoice report.

I have implemented this code, but it only sends an email to an email address that i have inputted in the code and it sends all records in the report (all customers invoices).

DoCmd.SendObject acSendReport, "rptInvoice", acFormatHTML, "mail@badlard.plus.com", , , "Invoice -- Jon Adlard Surveyor/Estimator", "This is your invoice"

How can i send a report to a customer via the same combo box?
 
Ive implemented your example Pat, but have decided to develop my appraoach.

There are now three options in fraprintoption, preview, print and email. The email function works with the specific report as the attachment, but when MS Outlook is loaded up the surname of the customer appears in the To: column rather than the email address.

Here is my code Pat i would grately appreciate it if you had a look and see where my problem is occuring.

Also when i select preview -- select a customer -- and click the button MS Outlook still loads up?!?

Private Sub OpenrptInvoice_Click()

On Error GoTo Err_OpenrptInvoice_Click

Dim strDocName As String
Dim PrintMode As Integer
Dim strWhere As String
Dim stDocName As String
Dim stEmail As String
Dim stSubject As String
Dim stBody As String

strWhere = ""

If Me.fraprintoption = 2 Then
PrintMode = acNormal
Else
PrintMode = acPreview
End If

strWhere = "[Surname] = """ & Me.[CmbRetrieveCustomer] & """"
strDocName = "rptInvoice"
DoCmd.OpenReport strDocName, PrintMode, , strWhere

If Me.fraprintoption = 3 Then 'Dodgy bit, have i set the right variables??
PrintMode = acNormal
Else
PrintMode = acNormal
End If

stDocName = "rptInvoice"
stEmail = " = """ & Me.[CmbRetrieveCustomer] & """"
stSubject = "--Invoice-- Jon Adlard Surveying Services"
stBody = "This find enclosed a copy of your invoice"
DoCmd.SendObject acReport, stDocName, acFormatRTF, stEmail, , , stSubject, stBody, True


Exit_OpenrptInvoice_Click:
Exit Sub

Err_OpenrptInvoice_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_OpenrptInvoice_Click
End Sub
 

Attachments

  • frmlinkinvoice1.jpg
    frmlinkinvoice1.jpg
    30.2 KB · Views: 180
Yeah the email address is stored in the combo box.

I didnt want to 'hardcode' the email in, because it is subject to change (user could select different customer with a different email address)
 

Users who are viewing this thread

Back
Top Bottom