Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Reports

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 12-24-2009, 08:04 AM
cynthiacorley cynthiacorley is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: Dec 2009
Posts: 1
cynthiacorley is on a distinguished road
Default Print a specific record report from a form

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!
Attached Files
File Type: zip testdb.zip (94.2 KB, 14 views)
Reply With Quote
  #2  
Old 12-24-2009, 10:48 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows XP Access 2002 (version 10.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #3  
Old 01-20-2010, 11:58 AM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 01-20-2010, 12:38 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #5  
Old 01-20-2010, 01:13 PM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

Thanks.
It works perfect.
Now, how can I select which printer that specific report will go to?
Reply With Quote
  #6  
Old 01-20-2010, 01:24 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #7  
Old 01-21-2010, 02:59 AM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

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.
Reply With Quote
  #8  
Old 01-21-2010, 03:45 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #9  
Old 01-21-2010, 03:50 AM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

Thanks RG
I'll see if I can work out the code.
Reply With Quote
  #10  
Old 01-21-2010, 02:19 PM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

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.
Reply With Quote
  #11  
Old 01-22-2010, 06:17 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #12  
Old 01-22-2010, 07:16 AM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

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.
Reply With Quote
  #13  
Old 01-22-2010, 10:46 AM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
  #14  
Old 01-29-2010, 11:07 AM
bbylls bbylls is offline Windows Vista Access 2003 (version 11.0)
Advanced Beginner
 
Join Date: Dec 2009
Posts: 33
bbylls is on a distinguished road
Default

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
I think I am close, but just don't have the knowledge to finalize it.
Please help.
Thanks
Reply With Quote
  #15  
Old 01-29-2010, 12:50 PM
RuralGuy's Avatar
RuralGuy RuralGuy is online now Windows 7 Access 2007 (version 12.0)
Administrator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 4,263
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

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"
Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -8. The time now is 02:48 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.