A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Using a Command Button to Print



 
 
Thread Tools Display Modes
  #1  
Old December 21st, 2006, 06:06 PM posted to microsoft.public.access.forms
Nanette
external usenet poster
 
Posts: 151
Default Using a Command Button to Print

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?
  #2  
Old December 21st, 2006, 07:20 PM posted to microsoft.public.access.forms
FL
external usenet poster
 
Posts: 161
Default Using a Command Button to Print

I had this same problem yesterday. There are a couple solutions I found.
First, try printing from the main menu while your in form view. Go to the
record you want to print then go to File - Print from Access menu. In the
window that opens select "Selected Records" in the Print Range section
(botton left corner of window). It will print your current record only on
the Form format you see on screen. Try it then you may need to go to Page
Setup if it needs to be Landscape or Portrait page layout format. Let me
know if this works. Post your reply. There's another solution if not.
--
FL


"Nanette" wrote:

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?

  #3  
Old December 21st, 2006, 07:24 PM posted to microsoft.public.access.forms
Jeff C
external usenet poster
 
Posts: 392
Default Using a Command Button to Print

The way I do is to open my form in design view and then SaveAs as report. I
then open the new report in desing view and perform the minor re-formatting
required.. I then copy the query being used as the record source for the
form, and save it with a new name, I add criteria to the one of the fields in
the query referencing the form (ex: forms!myform.IDField). This way the only
record returned by the query is the current record in the form.

Make this new query the record source for your new report.

Replace the report in your code with the new report.
--
Jeff C
Live Well .. Be Happy In All You Do


"Nanette" wrote:

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?

  #4  
Old December 21st, 2006, 07:31 PM posted to microsoft.public.access.forms
FL
external usenet poster
 
Posts: 161
Default Using a Command Button to Print

Jeff stated the other solution that I tried. It works. You can setup a
macro to run the query and report that Jeff mentioned, then add a button on
your form to runt the macro and print select records based on user entry.
This is what I did.
--
FL


"Jeff C" wrote:

The way I do is to open my form in design view and then SaveAs as report. I
then open the new report in desing view and perform the minor re-formatting
required.. I then copy the query being used as the record source for the
form, and save it with a new name, I add criteria to the one of the fields in
the query referencing the form (ex: forms!myform.IDField). This way the only
record returned by the query is the current record in the form.

Make this new query the record source for your new report.

Replace the report in your code with the new report.
--
Jeff C
Live Well .. Be Happy In All You Do


"Nanette" wrote:

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?

  #5  
Old December 21st, 2006, 07:36 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Using a Command Button to Print

On Thu, 21 Dec 2006 10:06:00 -0800, Nanette wrote:

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?


1) Forms are not really suitable for printing.
Create a report that displays the data you want.
Print that.

2) If you must print the form with all of it's buttons, backcolor,
etc., then right-click on the form name in the main database window.
Select Save As then select Report and name the report.
Print this report instead of the form.

3) Every record in your table should have a Unique Prime Key field
that uniquely identifies each record. Often it's an Autonumber field.

Code a command button click event:

DoCmd.OpenReport "ReportName",acViewPreview, , "[RecordID] = " &
Me![RecordID]

The above assumes [RecordID] is a Number datatype field.
If it is a Text datatype, then use:

DoCmd.OpenReport "ReportName",acViewPreview, , "[RecordID] = '" &
Me![RecordID] & "'"

Change [RecordID to whatever the actual name of your Prime Key field
is.

Only the record that matches the [RecordID] displayed on the form will
preview.

To print without preview, change acViewPreview to acViewNormal.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #6  
Old December 21st, 2006, 10:26 PM posted to microsoft.public.access.forms
Nanette
external usenet poster
 
Posts: 151
Default Using a Command Button to Print

Thanks FL,

I was hoping for something simplier, but I'll learn how to do this!

"FL" wrote:

Jeff stated the other solution that I tried. It works. You can setup a
macro to run the query and report that Jeff mentioned, then add a button on
your form to runt the macro and print select records based on user entry.
This is what I did.
--
FL


"Jeff C" wrote:

The way I do is to open my form in design view and then SaveAs as report. I
then open the new report in desing view and perform the minor re-formatting
required.. I then copy the query being used as the record source for the
form, and save it with a new name, I add criteria to the one of the fields in
the query referencing the form (ex: forms!myform.IDField). This way the only
record returned by the query is the current record in the form.

Make this new query the record source for your new report.

Replace the report in your code with the new report.
--
Jeff C
Live Well .. Be Happy In All You Do


"Nanette" wrote:

I've create a command button to print.

Private Sub Print_Report_Click()
On Error GoTo Err_Print_Report_Click

DoCmd.PrintOut acSelection, 1, 1

Exit_Print_Report_Click:
Exit Sub

Err_Print_Report_Click:
MsgBox Err.Description
Resume Exit_Print_Report_Click

End Sub

This keeps printing every page in the form.

I'd like to print only the current form showing on the screen. How can I do
this?

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.