P
Peter Fletcher
I am writing an application which needs to print labels to printers on
computers to which I do not have physical access - they are on the other side
of the Atlantic. To add to the fun, my users are running the application
under the Access runtime, so they don't have access to the Page Setup menu
for Reports.
I have found from experience that it is not enough to set the report up to
use a specified label blank - some "tuning" of (particularly) the top and
bottom margin settings is needed to position the printed output squarely on
the labels on a given printer. I would like to give my users a form that
allows them to adjust the margins so that a test Report prints out correctly,
and then programmatically apply the settings to the real Reports. All I
thought I would have to do was to change the relevant Me.Printer.xxxMargin
settings on the basis of saved offset values in code running at the On Open
Event. However, as noted in an earlier post, to which no-one has yet
responded, the Open Event does not seem to fire at all if a Report is opened
in Normal mode by DoCmd.OpenReport. I therefore tried opening the Report in
preview mode, modifying the relevant settings, and saving it, before printing
it. Everything appears to work, the new settings can be seen in the Printer
Setup dialog of the open preview window, and printing from it before closing
the Report produces an appropriately modified printout. However, the changes
are lost when the Report is closed, even with acSaveYes specified. Even
opening the Report (from code) in Design View still does not allow the
changes to be saved. See code example below - txtVOffset and txtHOffset are
the relevant "offset" controls on the Form:
.....
DoCmd.OpenReport "labelsTest", acViewDesign
Set repLabels = Reports("LabelsTest")
With repLabels.Printer
.TopMargin = .TopMargin + (txtVOffset * 1440)
.BottomMargin = .BottomMargin - (txtVOffset * 1440)
.LeftMargin = .LeftMargin + (txtHOffset * 1440)
.RightMargin = .RightMargin - (txtHOffset * 1440)
End With
DoCmd.Close acReport, "labelsTest", acSaveYes
Why is this not working? If the problem results from a known bug, is there a
workaround?
computers to which I do not have physical access - they are on the other side
of the Atlantic. To add to the fun, my users are running the application
under the Access runtime, so they don't have access to the Page Setup menu
for Reports.
I have found from experience that it is not enough to set the report up to
use a specified label blank - some "tuning" of (particularly) the top and
bottom margin settings is needed to position the printed output squarely on
the labels on a given printer. I would like to give my users a form that
allows them to adjust the margins so that a test Report prints out correctly,
and then programmatically apply the settings to the real Reports. All I
thought I would have to do was to change the relevant Me.Printer.xxxMargin
settings on the basis of saved offset values in code running at the On Open
Event. However, as noted in an earlier post, to which no-one has yet
responded, the Open Event does not seem to fire at all if a Report is opened
in Normal mode by DoCmd.OpenReport. I therefore tried opening the Report in
preview mode, modifying the relevant settings, and saving it, before printing
it. Everything appears to work, the new settings can be seen in the Printer
Setup dialog of the open preview window, and printing from it before closing
the Report produces an appropriately modified printout. However, the changes
are lost when the Report is closed, even with acSaveYes specified. Even
opening the Report (from code) in Design View still does not allow the
changes to be saved. See code example below - txtVOffset and txtHOffset are
the relevant "offset" controls on the Form:
.....
DoCmd.OpenReport "labelsTest", acViewDesign
Set repLabels = Reports("LabelsTest")
With repLabels.Printer
.TopMargin = .TopMargin + (txtVOffset * 1440)
.BottomMargin = .BottomMargin - (txtVOffset * 1440)
.LeftMargin = .LeftMargin + (txtHOffset * 1440)
.RightMargin = .RightMargin - (txtHOffset * 1440)
End With
DoCmd.Close acReport, "labelsTest", acSaveYes
Why is this not working? If the problem results from a known bug, is there a
workaround?