Print Preview report of current record

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.
 
B

Bandit

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
 
C

Chris 1

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.


.
 
C

Chris1

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.
.
.
 

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