![]() |
|
|
#1
|
|||
|
|||
|
I can't seem to print a report on the specific record that I have opened on the form. I have tried using a macro with an Open Report and WHERE condition and also tried a stored procedure. Can't seem to get either one to work. I have enclosed a very simplified version of my database and what I need to do. I'm kind of new to macros and procedures, so please provide detailed instructions. Thanks in advance for your help!
|
|
#2
|
||||
|
||||
|
Hi Cynthia,
It seems to work just fine for me. The report is only for the selected Order_No.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#3
|
|||
|
|||
|
I am trying to do the same thing.
I cannot open her database because it is 2007 and I am 2003. I would like to see the code that makes this work. Can you post the code for printing just the record currently on the form. Thank you. |
|
#4
|
||||
|
||||
|
Have you seen this link?
http://www.mvps.org/access/reports/rpt0002.htm
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#5
|
|||
|
|||
|
Thanks.
It works perfect. Now, how can I select which printer that specific report will go to?
|
|
#6
|
||||
|
||||
|
Unless you are changing the printer all of the time, each report will remember which printer to use if when in design mode for the report you go to File>Print and select a printer.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#7
|
|||
|
|||
|
Yes, I would like the option to change the printer when I print a report.
I would like the option to send it to my printer, or maybe my bosses printer, or maybe to make a pdf file. Thanks. |
|
#8
|
||||
|
||||
|
To do this with a macro, first you would use an OpenReport action to
Preview the report, and then the RunCommand/Print action which will open the print dialog.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#9
|
|||
|
|||
|
Thanks RG
I'll see if I can work out the code. |
|
#10
|
|||
|
|||
|
I'm close.
This is my code: Dim stDocName As String stDocName = "Packer" StrFilter = "[packer#]=" & Me.packer_ DoCmd.OpenReport stDocName, acPreview, , StrFilter DoCmd.RunCommand acCmdPrint DoCmd.OpenReport stDocName, acNormal, , StrFilter I get a blank preview and the printer dialog box. After I select the printer, the preview then shows up and it prints 2 copies to the correct printer. What's missing? Thanks. |
|
#11
|
||||
|
||||
|
You need to have Option Explicit at the top of your Class module and then Debug>Compile your code. It should throw an error.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#12
|
|||
|
|||
|
This is the complete code:
Private Sub PrintPacker_Click() On Error GoTo Err_PrintPacker_Click Dim stDocName As String stDocName = "Packer" StrFilter = "[packer#]=" & Me.packer_ DoCmd.OpenReport stDocName, acPreview, , StrFilter DoCmd.RunCommand acCmdPrint DoCmd.OpenReport stDocName, acNormal, , StrFilter Exit_PrintPacker_Click: Exit Sub Err_PrintPacker_Click: MsgBox Err.Description Resume Exit_PrintPacker_Click End Sub I am not familiar with all of the Access terminology as I am a newby at this, so I am not sure what you are talking about. |
|
#13
|
||||
|
||||
|
The top of your code module should start with these two lines:
Option Compare Database Option Explicit Then while looking at your code go to Debug>Compile and compile your code, please.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
#14
|
|||
|
|||
|
These are at the beginning of the code:
Option Compare Database Option Explicit I ran the debug and found a missing line. I have been playing around and not had any luck. I have a form with a button on it that I want to print the current record on a report. Using the following code, I get a blank preview and the printer select dialog box, I choose the printer I want to print the report on, but the report prints on the default printer, and the form prints on the selected printer. Code:
Private Sub PrintPacker_Click()
On Error GoTo Err_PrintPacker_Click
Dim stDocName As String
Dim StrFilter As String
stDocName = "Packer"
StrFilter = "[packer#]=" & Me.packer_
DoCmd.RunCommand acCmdPrint
DoCmd.OpenReport stDocName, acPreview, , StrFilter
DoCmd.OpenReport stDocName, acNormal, , StrFilter
Exit_PrintPacker_Click:
Exit Sub
Err_PrintPacker_Click:
MsgBox Err.Description
Resume Exit_PrintPacker_Click
End Sub
Please help. Thanks |
|
#15
|
||||
|
||||
|
Try:
Code:
Private Sub PrintPacker_Click()
On Error GoTo Err_PrintPacker_Click
Dim stDocName As String
Dim StrFilter As String
stDocName = "Packer"
StrFilter = "[packer#]=" & Me.packer_
DoCmd.OpenReport stDocName, acPreview, , StrFilter
DoCmd.RunCommand acCmdPrint
' DoCmd.OpenReport stDocName, acNormal, , StrFilter
Exit_PrintPacker_Click:
Exit Sub
Err_PrintPacker_Click:
MsgBox Err.Description
Resume Exit_PrintPacker_Click
End Sub
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07 If your issue is resolved...follow this link for directions on how to use the Solved thread tool! Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus" |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| print continued at bottom of report | ecpike | Reports | 2 | 02-25-2010 11:50 AM |
Print Report from Form ID
|
Brian62 | Forms | 1 | 09-18-2009 11:50 AM |
| List Box in Form is causing black boxes to print on a report | tigers | Forms | 1 | 07-30-2009 10:54 AM |
| Print a different image per record | mcaldwell | Reports | 5 | 04-24-2009 12:00 PM |
| How do I get a line not to print on a report... | tigers | Reports | 3 | 03-24-2006 05:40 AM |