printing current record

G

Guest

I am tring to have the current record viewed in a form to print with a
report. I can't seam to get it to work. It will open the report but not
refernceing the correct record number. Can some please help me out.

Private Sub CmdPrint_Click()
On Error GoTo Err_CmdPrint_Click

DoCmd.OpenReport "PrintRMA", acViewPreview
Reports![PrintRMA].Filter = "RMATbl.RcdID" = "& Me![RcdID]"
Reports![PrintRMA].FilterOn = True


Exit_CmdPrint_Click:
Exit Sub

Err_CmdPrint_Click:
MsgBox Err.Description
Resume Exit_CmdPrint_Click

End Sub
 
F

fredg

I am tring to have the current record viewed in a form to print with a
report. I can't seam to get it to work. It will open the report but not
refernceing the correct record number. Can some please help me out.

Private Sub CmdPrint_Click()
On Error GoTo Err_CmdPrint_Click

DoCmd.OpenReport "PrintRMA", acViewPreview
Reports![PrintRMA].Filter = "RMATbl.RcdID" = "& Me![RcdID]"
Reports![PrintRMA].FilterOn = True


Exit_CmdPrint_Click:
Exit Sub

Err_CmdPrint_Click:
MsgBox Err.Description
Resume Exit_CmdPrint_Click

End Sub
Access and VBA help files are your friend.
A look in VBA help at the OpenReport method would have given you your
answer.

Look up, in VBA help:
OpenReport for the various arguments.
And then:
Restrict Data to a subset of records
to learn how to write a Where clause for the different types of
datatype..

What is the datatype of RcdID?
If it is a Number datatype, then use:

Private Sub CmdPrint_Click()
On Error GoTo Err_CmdPrint_Click
DoCmd.OpenReport "PrintRMA", acViewPreview, , "RcdID = "& Me![RcdID]
Exit_CmdPrint_Click:
Exit Sub

Err_CmdPrint_Click:
MsgBox Err.Description
Resume Exit_CmdPrint_Click

End Sub

However, if it is a Text datatype, then use:

DoCmd.OpenReport "PrintRMA", acViewPreview, , "RcdID = '"& Me![RcdID]
& "'"
 

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