in message:
YES Thankyou!!!!!
Was that "Yes" to my question about setting up the form?
If so, we can create something very generic and then you
can customize it to your hearts content.
1. Create a new blank form (not using the wizard) and do
not give it a Recordsource.
2. With the control wizards enabled drop a new command
button on the form. The wizard will then take you through
a quick series of steps.
3. On the first screen select the option in the left list box called
"Report Operations." On the right side choose "Preview Report."
Hit Next.
4. On the next screen, select the report you want to open from
the list provided. Hit Next.
5. On the next screen you can either choose to display a text
message on the command button or a picture. I'll let you decide
which one you would like. Hit Next when ready.
6. On the last screen we need to name this command. Name it
cmdPreviewReport and then hit the Finish button.
7. The wizard will close and you can now see your command
button. Right click on that button and select Properties from
the list provided.
8. On the Event or All tabs look for an option called "On Click."
You will notice it says [Event Procedure]. This means there is
some code attached to that particular control event. Hit the button
just to the right of this line that has the three dots on it [...]
You will now be taken to the code window for this form and
specifically the Click event for this command button.
9. The wizard will have created "similar" to the following:
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim stDocName As String
stDocName = "YourReportNameHere"
DoCmd.OpenReport stDocName, acPreview
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
10. What we need to do is add one more line of code to this procedure
just below the DoCmd line like so:
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim stDocName As String
stDocName = "YourReportNameHere"
DoCmd.OpenReport stDocName, acPreview
DoCmd.RunCommand acCmdZoom100
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
11. Now save and close the form and give it a meaningful name.
12. Open the form in normal view and press the button. Presto,
the report opens up and set at 100%!!
13. Now if you want to have the report be maximized AND 100%
then just go back to the form code and add in one more line like so:
Private Sub cmdPreviewReport_Click()
On Error GoTo Err_cmdPreviewReport_Click
Dim stDocName As String
stDocName = "YourReportNameHere"
DoCmd.OpenReport stDocName, acPreview
DoCmd.Maximize
DoCmd.RunCommand acCmdZoom100
Exit_cmdPreviewReport_Click:
Exit Sub
Err_cmdPreviewReport_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewReport_Click
End Sub
14. That's it!!
Hope that helps,