Printing forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to allow the user to print the form that I am creating. I am running
into two problems:

1. I keep receiving an error that the form is too wide for the page, and
there are blank pages every other page because of this when viewing print
preview. I can not locate anything on this form that is over the page width
- I have fiddled endlessly with the margins and shrunk the data on the page,
but it keeps running over. Suggestions?

2. I want to create an option that allows the user to print the form for a
single entry. Currently, when the form is printed, all 300 records are
printed. How can I limit this or include some selection that allows the user
to choose which record they wish to print?

Any insight is much appreciated! (if it wasnt readily apparent, I have no
VB/coding skills, and am fighting have to code this thing at all costs!) :)
 
BLV 06 said:
I want to allow the user to print the form that I am creating. I am running
into two problems:

1. I keep receiving an error that the form is too wide for the page, and
there are blank pages every other page because of this when viewing print
preview. I can not locate anything on this form that is over the page width
- I have fiddled endlessly with the margins and shrunk the data on the page,
but it keeps running over. Suggestions?

2. I want to create an option that allows the user to print the form for a
single entry. Currently, when the form is printed, all 300 records are
printed. How can I limit this or include some selection that allows the user
to choose which record they wish to print?

Any insight is much appreciated! (if it wasnt readily apparent, I have no
VB/coding skills, and am fighting have to code this thing at all costs!)
:)

Forms suck for printing. Design a report and both problems you now have
are easily dealt with.

For a quick start right-click on your form in the db window and choose
"Save as Report".
 
I agree about printing reports rather than forms. Optimal display on paper
is rarely the same as on screen, for one thing. For another, the screen and
a piece of paper are proportioned differently. Easy to convert a form to a
report. In form design view place a command button on the form to preview or
print the report. You can use the wizard, but you should know that the
wizard uses code, and you will need to also. Not to fear. Create a command
button on the form (no wizard). Right click and select Properties (or double
click). The box that showed up is the property sheet. Click the Event tab
at the top, then click the white space next to On Click. Click the three
dots that appear, click Code Builder, then OK. Where the cursor appears,
type:

Dim LinkCriteria As String

stLinkCriteria = "[MainID]=" & Me![MainID]
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptMyReport", acPreview, , _ stLinkCriteria
Exit Sub

This assumes that the Primary Key for the record you want to print is named
MainID, and that your report is named rptMyReport. Substitute acNormal for
acPreview to print directly without previewing.
Try creating a command button using the wizard. Open the property sheet and
compare the code. It will be a bit more complex, with instructions about a
procedure to follow in case of an error, and with an extra two lines of code
referring to DocName, but it will accomplish pretty much the same thing.
 
Thanks to both of you. Bruce - I tried creating the command button, however
I am receiveing a syntax error with this line of code: DoCmd.OpenReport
"rptMyReport", acPreview, , _ stLinkCriteria

Question (could be a stupid one - no laughing :) )
- do I have to create rptMyReport first? (I will look into doing this in the
meantime)

Thanks!
~Betsy

Bruce said:
I agree about printing reports rather than forms. Optimal display on paper
is rarely the same as on screen, for one thing. For another, the screen and
a piece of paper are proportioned differently. Easy to convert a form to a
report. In form design view place a command button on the form to preview or
print the report. You can use the wizard, but you should know that the
wizard uses code, and you will need to also. Not to fear. Create a command
button on the form (no wizard). Right click and select Properties (or double
click). The box that showed up is the property sheet. Click the Event tab
at the top, then click the white space next to On Click. Click the three
dots that appear, click Code Builder, then OK. Where the cursor appears,
type:

Dim LinkCriteria As String

stLinkCriteria = "[MainID]=" & Me![MainID]
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptMyReport", acPreview, , _ stLinkCriteria
Exit Sub

This assumes that the Primary Key for the record you want to print is named
MainID, and that your report is named rptMyReport. Substitute acNormal for
acPreview to print directly without previewing.
Try creating a command button using the wizard. Open the property sheet and
compare the code. It will be a bit more complex, with instructions about a
procedure to follow in case of an error, and with an extra two lines of code
referring to DocName, but it will accomplish pretty much the same thing.

BLV 06 said:
I want to allow the user to print the form that I am creating. I am running
into two problems:

1. I keep receiving an error that the form is too wide for the page, and
there are blank pages every other page because of this when viewing print
preview. I can not locate anything on this form that is over the page width
- I have fiddled endlessly with the margins and shrunk the data on the page,
but it keeps running over. Suggestions?

2. I want to create an option that allows the user to print the form for a
single entry. Currently, when the form is printed, all 300 records are
printed. How can I limit this or include some selection that allows the user
to choose which record they wish to print?

Any insight is much appreciated! (if it wasnt readily apparent, I have no
VB/coding skills, and am fighting have to code this thing at all costs!) :)
 
The whole point of the command button is to open a report, so the report
needs to exist before the command button code will be relevant. Right now
you are telling it to open a report, and the command button is saying "Huh?"
as if you had invited it to go swimming before the pool was built. Ah,
Friday afternoon.

BLV 06 said:
Thanks to both of you. Bruce - I tried creating the command button, however
I am receiveing a syntax error with this line of code: DoCmd.OpenReport
"rptMyReport", acPreview, , _ stLinkCriteria

Question (could be a stupid one - no laughing :) )
- do I have to create rptMyReport first? (I will look into doing this in the
meantime)

Thanks!
~Betsy

Bruce said:
I agree about printing reports rather than forms. Optimal display on paper
is rarely the same as on screen, for one thing. For another, the screen and
a piece of paper are proportioned differently. Easy to convert a form to a
report. In form design view place a command button on the form to preview or
print the report. You can use the wizard, but you should know that the
wizard uses code, and you will need to also. Not to fear. Create a command
button on the form (no wizard). Right click and select Properties (or double
click). The box that showed up is the property sheet. Click the Event tab
at the top, then click the white space next to On Click. Click the three
dots that appear, click Code Builder, then OK. Where the cursor appears,
type:

Dim LinkCriteria As String

stLinkCriteria = "[MainID]=" & Me![MainID]
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenReport "rptMyReport", acPreview, , _ stLinkCriteria
Exit Sub

This assumes that the Primary Key for the record you want to print is named
MainID, and that your report is named rptMyReport. Substitute acNormal for
acPreview to print directly without previewing.
Try creating a command button using the wizard. Open the property sheet and
compare the code. It will be a bit more complex, with instructions about a
procedure to follow in case of an error, and with an extra two lines of code
referring to DocName, but it will accomplish pretty much the same thing.

BLV 06 said:
I want to allow the user to print the form that I am creating. I am running
into two problems:

1. I keep receiving an error that the form is too wide for the page, and
there are blank pages every other page because of this when viewing print
preview. I can not locate anything on this form that is over the page width
- I have fiddled endlessly with the margins and shrunk the data on the page,
but it keeps running over. Suggestions?

2. I want to create an option that allows the user to print the form for a
single entry. Currently, when the form is printed, all 300 records are
printed. How can I limit this or include some selection that allows the user
to choose which record they wish to print?

Any insight is much appreciated! (if it wasnt readily apparent, I have no
VB/coding skills, and am fighting have to code this thing at all costs!) :)
 
Back
Top