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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|