Hi June, thanks.
I've now got items 1 and 2 working OK. I prefer to keep each item on a seperate button, as the tasks are usually performed at different times (ie the email is sent first then a few days later we create one or other of the labels).
So, all I need now is the vba code to do the same job as the code below, but instead of opening a report and printing it, I need it to retrieve the customer's email address from the current record being viewed in the form and email a PDF attachment on the desktop.
Would you be able to write the code, based on the one I've included below?
The name of the form from which the current record is taken is called "GRA Records". The table / field that contains the email address is "Ebay Sales Records" / "Buyer email" (this table provides the data in a subform that is part of the main form "GRA Records". The PDF Document is called "GRA FORM and the filepath to it is "C:\Users\Mike\Desktop\"
if I understand correctly, the part of the code
Code:
strWhere = "[Sales record number] = """ & Me.[Sales Record Number] & """"
is the bit that ensures the current viewed record in the "GRA Records" form is the only record selected when the tasks run.
Sorry to appear thick, but in all honesty when it comes to VBA I'm a pure novice just starting out; I'm learning as I get finished codes that work, but putting them together in the first place is my weakness.
Here's the code that does the label print in item 1:
Code:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[Sales record number] = """ & Me.[Sales Record Number] & """"
DoCmd.OpenReport "4x3 Labels UK 2nd Class post label output GRA", acViewPreview, , strWhere
End If
End Sub
Thanks in advance
B Rgds
Mike