Printing a report from the current record only

  • Thread starter Thread starter FrunkaBlunka
  • Start date Start date
F

FrunkaBlunka

Hi everybody,

I have noticed that there are lots of topics similar to this one
however i have tried some of the code from the others and they dont
seem to work for me. My records are identified by the JobID which is a
number datatype.

Basically what I am trying to achieve a command button on the my form
that when pressed previews a report showing the current record data
only. At the moment the report displays all the records and not just
the one that is currently being viewed in the form.

The button I am using is called - cmdFrontSheet
The form is called - frmMainform
The report I wish to display is called - rptProjectDetails
The table which my report is based on is called - tblProjectDetails the
field JobID

Any help is great help!

Thanks
 
This should be an easy fix. Think I found exactly what you are looking
for.

Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[JobID]=" & me!JobID
DoCmd.OpenReport strDocName, acPreview, , strWhere

and here's the link:

http://www.mvps.org/access/reports/rpt0002.htm

It might also be simpler to add a WHERE clause to the end of your
report's recordource.

Hope this helps.
 
Thanks works perfectly now! ;)
This should be an easy fix. Think I found exactly what you are looking
for.

Dim strDocName As String
Dim strWhere As String
strDocName = "rptSomeReport"
strWhere = "[JobID]=" & me!JobID
DoCmd.OpenReport strDocName, acPreview, , strWhere

and here's the link:

http://www.mvps.org/access/reports/rpt0002.htm

It might also be simpler to add a WHERE clause to the end of your
report's recordource.

Hope this helps.
Hi everybody,

I have noticed that there are lots of topics similar to this one
however i have tried some of the code from the others and they dont
seem to work for me. My records are identified by the JobID which is a
number datatype.

Basically what I am trying to achieve a command button on the my form
that when pressed previews a report showing the current record data
only. At the moment the report displays all the records and not just
the one that is currently being viewed in the form.

The button I am using is called - cmdFrontSheet
The form is called - frmMainform
The report I wish to display is called - rptProjectDetails
The table which my report is based on is called - tblProjectDetails the
field JobID

Any help is great help!

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

Back
Top