Print Preview report of current record

  • Thread starter Thread starter Chris1
  • Start date Start date
C

Chris1

Hi,

I want to be able to print preview the report of mu
current record on my form. I have created a button and
entered the following code on its OnClick event:

Private Sub Command74_Click()
DoCmd.OpenReport "Complaint & Investigation",
acViewPreview, , "[ComplaintNumberID]= " &
[ComplaintNumberID]

End Sub

The problem is that when I press the button, the report
shows up but it is blank. I have to use the record
navigation buttons on the form back and forth once, press
the report button again in order to see the current data
on report.
Is there any way I can avoid this problem and see the data
straight away?
Any help much appreciated.
Chris.
 
Good Morning:

This should work-

DoCmd.OpenReport "Complaint &
Investigation",acViewPreview,, "[ComplaintNumberID]=Forms!
frmComplaint!ComplaintNumberID"

frmComplaint is whatever the form name is.

Have a Great Weekend...

Bandit
 
Thanks a lot for the tip, it worked a wonder!

Have a great weekend!
Chris
-----Original Message-----
Is it possible that the record in the form has not been saved yet?

The code in this article explains how to save first, and check there is a
record to print:
Print the record in the form
at:
http://members.iinet.net.au/~allenbrowne/casu-15.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Hi,

I want to be able to print preview the report of mu
current record on my form. I have created a button and
entered the following code on its OnClick event:

Private Sub Command74_Click()
DoCmd.OpenReport "Complaint & Investigation",
acViewPreview, , "[ComplaintNumberID]= " &
[ComplaintNumberID]

End Sub

The problem is that when I press the button, the report
shows up but it is blank. I have to use the record
navigation buttons on the form back and forth once, press
the report button again in order to see the current data
on report.
Is there any way I can avoid this problem and see the data
straight away?
Any help much appreciated.
Chris.


.
 
Thanks a lot for the reply.

Have a great weekend too!
Chris.
-----Original Message-----
Good Morning:

This should work-

DoCmd.OpenReport "Complaint &
Investigation",acViewPreview,, "[ComplaintNumberID]=Forms!
frmComplaint!ComplaintNumberID"

frmComplaint is whatever the form name is.

Have a Great Weekend...

Bandit

-----Original Message-----
Hi,

I want to be able to print preview the report of mu
current record on my form. I have created a button and
entered the following code on its OnClick event:

Private Sub Command74_Click()
DoCmd.OpenReport "Complaint & Investigation",
acViewPreview, , "[ComplaintNumberID]= " &
[ComplaintNumberID]

End Sub

The problem is that when I press the button, the report
shows up but it is blank. I have to use the record
navigation buttons on the form back and forth once, press
the report button again in order to see the current data
on report.
Is there any way I can avoid this problem and see the data
straight away?
Any help much appreciated.
Chris.
.
.
 
Back
Top