print specific reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a report - that gets its data from a query - and I have a form that
lists the results from the query.

I would like to put a command button next to each record, and which ever
button I click, it will print only that data, not the entire query.

Can anyone help me please? I've been working on this all day and I'm going
nowhere fast.
 
Asked and answered pretty often in here...

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 = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field), you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with acViewNormal.



See also: http://allenbrowne.com/casu-15.html

See also: http://www.databasedev.co.uk/print_form_record.html
 
Thanks man, you're the greatest

Rick B said:
Asked and answered pretty often in here...

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 = "[ID] = " & Me.[ID]

DoCmd.OpenReport "MyReport", acViewPreview, , strWhere

End If

End Sub



Notes: If your primary key is a Text type field (not a Number type field), you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"

If you want the report to print without preview, replace acViewPreview with acViewNormal.



See also: http://allenbrowne.com/casu-15.html

See also: http://www.databasedev.co.uk/print_form_record.html


--
Rick B



coconut78 said:
I have a report - that gets its data from a query - and I have a form that
lists the results from the query.

I would like to put a command button next to each record, and which ever
button I click, it will print only that data, not the entire query.

Can anyone help me please? I've been working on this all day and I'm going
nowhere fast
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top