"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:3f***********************@news.dial.pipex.com ...
Is there a way to print/e-mail the current record as it appears on a form?
To print the current record, create a report, and use the primary key value
in the WhereCondition of the OpenReport action. The Click event procedure
for a command button to print the current record would look like this
(assuming an Autonumber primary key named "ID":
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Select a record to print."
Else
strWhere = "[ID] = " & Me.ID
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
To email, use SendObject.
SendObject does not have a WhereCondition.
Create a public variable by typing this into the General Declarations
section (top) of a standard module:
Public gstrReportFilter As String
Set the string before calling SendObject:
gstrReportFilter = Me.ID
In the Open event of the report, apply the filter so it contains only the
one record, and reset the string:
Private Sub Report_Open(Cancel As Integer)
If Len(gstrReportFilter) > 0 Then
Me.Filter = gstrReportFilter
Me.FilterOn = True
gstrReportFilter = vbNullString
End If
End Sub
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.