Print to Printer dispays value not on print preview of report

  • Thread starter AaronWestcott via AccessMonster.com
  • Start date
A

AaronWestcott via AccessMonster.com

Hello all,

I have a report that looks back at the previous 20 years of data and prints
the values and the % change from the previous year. All the data, including
the % change are contained in a table (not my doing). I have written some
code (see below) to not display the percent change of the first year reported.
The reports previews fine but when I print the value for % change for the
first record actually prints.

More Detail: I have a field TOTCHG that has the percent change stored in it.
I created a text box to display the value contained in TOTCHG except for the
first record. The code to do this is below.

Option Compare Database
Option Explicit

Dim counter As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If counter = 0 Then
Me.Text21 = ""
Else
Me.Text21 = Me.TOTCHG
End If
counter = counter + 1
End Sub

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)

End Sub

Any ideas that anybody may have would be greatly aprpeciated.

Aaron
 
M

Marshall Barton

AaronWestcott said:
I have a report that looks back at the previous 20 years of data and prints
the values and the % change from the previous year. All the data, including
the % change are contained in a table (not my doing). I have written some
code (see below) to not display the percent change of the first year reported.
The reports previews fine but when I print the value for % change for the
first record actually prints.

More Detail: I have a field TOTCHG that has the percent change stored in it.
I created a text box to display the value contained in TOTCHG except for the
first record. The code to do this is below.

Option Compare Database
Option Explicit

Dim counter As Integer

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If counter = 0 Then
Me.Text21 = ""
Else
Me.Text21 = Me.TOTCHG
End If
counter = counter + 1
End Sub


You can not use an event procedure to calculate a value
across multiplt records. Remove the counter and figure out
another way to determine when to display the value.

I don't see the need for the extra text box, can't you just
make the TOTCHG text box visible/invisible? I would expect
the values for the first year to be different form the other
years. Isn't the value in TOTCHG Null for thefirst year?
If so, you shouldn't have to do anything.

If it's the negative of the year value, then you could use
code like:

Me.TOTCHG.Visible = (Me.TOTCHG <> -Me.yearvalue)
 
A

AaronWestcott via AccessMonster.com

Thanks for the reply.

The table of values has more than 20 years and the percent change from the
previous year associated with it. The report simply prints out he last 20
years using a query to grab the most recent 20 years. So I used the code to
essentially make the first appearance of the percent change field blank.
This actually works when I preview the report. It fails when I try to
actually print the report.

Furthermore, I just got done trying to right click from the database window
on the report and selecting the print option. That works. the print out does
not have the first instance of the percent change field. However, when I
preview the report, the first instance of the percent change field is blank,
when I print from the preview mode the print out is populated with its value
from the query. I don't know if this is a bug in access or not but it sure
is strange.

I will try make the field not visible on the first instance and see if that
works.

Thanks,

Aaron
 
M

Marshall Barton

AaronWestcott said:
Thanks for the reply.

The table of values has more than 20 years and the percent change from the
previous year associated with it. The report simply prints out he last 20
years using a query to grab the most recent 20 years. So I used the code to
essentially make the first appearance of the percent change field blank.
This actually works when I preview the report. It fails when I try to
actually print the report.

Furthermore, I just got done trying to right click from the database window
on the report and selecting the print option. That works. the print out does
not have the first instance of the percent change field. However, when I
preview the report, the first instance of the percent change field is blank,
when I print from the preview mode the print out is populated with its value
from the query. I don't know if this is a bug in access or not but it sure
is strange.

I will try make the field not visible on the first instance and see if that
works.


That counter stuff might appear to work in some
circumstances, but it is frought with trouble. Even in
preview it can produce odd results if you jump around the
pages. Please take my word on this, it comes from some
painful experiences that seemed to work - until users
applied their innovative way of viewing reports.
 
A

AaronWestcott via AccessMonster.com

I understand. I took your advice and tried changing the visible property and
that worked. It is also cleaner. Thanks for you help.

Marshall said:
Thanks for the reply.
[quoted text clipped - 15 lines]
I will try make the field not visible on the first instance and see if that
works.

That counter stuff might appear to work in some
circumstances, but it is frought with trouble. Even in
preview it can produce odd results if you jump around the
pages. Please take my word on this, it comes from some
painful experiences that seemed to work - until users
applied their innovative way of viewing reports.
 

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