Current record to report and print

D

dogbite

I am trying to send the current record(form1) to (report1) and get it to
print.
I have things on the report that are not in the form1 mostly I get the form1
to print but not the rest of report1 or all the reports print (the whole
table). Ijust want to print 1 at a time. I would like to do it with a
cmdbutton if possible.
I'm new at this and don't understand a lot of it.
Thanks for any help
 
P

pietlinden

dogbite said:
I am trying to send the current record(form1) to (report1) and get it to
print.
I have things on the report that are not in the form1 mostly I get the form1
to print but not the rest of report1 or all the reports print (the whole
table). Ijust want to print 1 at a time. I would like to do it with a
cmdbutton if possible.
I'm new at this and don't understand a lot of it.
Thanks for any help

If you're doing this from an open form, then it's pretty easy. If you
look at the OpenReport command, one of the arguments is a filter (a
valid WHERE clause, minus the word "WHERE"). Assuming you have a
textbox control on your form called txtSomeID that you wanted to print,
then you could do this:

The wizard will do 90 percent of this for you...

Private Sub cmdPreviewFilteredReport_Click()
On Error GoTo Err_cmdPreviewFilteredReport_Click

Dim stDocName As String
stDocName = "Catalog"

'---the only part it leaves out is the filter at the end (all the stuff
to the right of "acPreview"
'---Me.cboProduct is a combobox on the same form as the button...

DoCmd.OpenReport stDocName, acPreview, , "[ProductName]='" &
Me.cboProduct & "'"

Exit_cmdPreviewFilteredReport_Click:
Exit Sub

Err_cmdPreviewFilteredReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewFilteredReport_Click

End Sub
 
D

dogbite via AccessMonster.com

I am trying to send the current record(form1) to (report1) and get it to
print.
[quoted text clipped - 4 lines]
I'm new at this and don't understand a lot of it.
Thanks for any help

If you're doing this from an open form, then it's pretty easy. If you
look at the OpenReport command, one of the arguments is a filter (a
valid WHERE clause, minus the word "WHERE"). Assuming you have a
textbox control on your form called txtSomeID that you wanted to print,
then you could do this:

The wizard will do 90 percent of this for you...

Private Sub cmdPreviewFilteredReport_Click()
On Error GoTo Err_cmdPreviewFilteredReport_Click

Dim stDocName As String
stDocName = "Catalog"

'---the only part it leaves out is the filter at the end (all the stuff
to the right of "acPreview"
'---Me.cboProduct is a combobox on the same form as the button...

DoCmd.OpenReport stDocName, acPreview, , "[ProductName]='" &
Me.cboProduct & "'"

Exit_cmdPreviewFilteredReport_Click:
Exit Sub

Err_cmdPreviewFilteredReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewFilteredReport_Click

End Sub


I put a cmdbutton on the form copied your code used cmdPrint, frmlkwls,
rptlkwls entered in the code "Private sub cmdPrint_click) it wants to print
the whole table. I just want to take the current data from the form sent it
to the report and print it. Did I do it wrong? Like I said I'm real new at
this please be patient.
thanks
 

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

Top