Printing Current Record on SubForm

  • Thread starter Thread starter Matt Reed
  • Start date Start date
M

Matt Reed

I have a form with an attached subform used to show seminar articles
It is working to the point where I can selected an author on the form and
the subform shows just the articles by that author. There maybe more than
one article by that person.
On the sub form I can cycle through those articles.
The question is, when I find the correct article how can I print out just
that article?

Matt
 
Use the primary key of the articles table in the WhereCondition of the
OpenReport action. (This assumes you have a report laid out for printing
articles.)

This example shows the code you might put into the Click event of a button
on your main form to open a report named "rptArticle", based on a primary
key (autonumber) field named "ArticleID":

Private Sub cmdPrintActicle_Click()
Dim strWhere As String
With Me.[NameOfYourSubformControlHere].Form
If .NewRecord Then
MsgBox "Select an article first."
Else
strWhere = "ArticleID = " & !ArticleID
DoCmd.OpenReport "rptArticle", acViewPreview, , strWhere
End If
End With
End Sub
 
Thanks, I'll give that a try.

Matt

Use the primary key of the articles table in the WhereCondition of the
OpenReport action. (This assumes you have a report laid out for printing
articles.)

This example shows the code you might put into the Click event of a button
on your main form to open a report named "rptArticle", based on a primary
key (autonumber) field named "ArticleID":

Private Sub cmdPrintActicle_Click()
Dim strWhere As String
With Me.[NameOfYourSubformControlHere].Form
If .NewRecord Then
MsgBox "Select an article first."
Else
strWhere = "ArticleID = " & !ArticleID
DoCmd.OpenReport "rptArticle", acViewPreview, , strWhere
End If
End With
End Sub
 
Back
Top