Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Divardo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    12

    Printing a quantity of a certain report in a form, how?

    Hi,



    What I have is an access database with one report which needs to be printed by the user a certain amount of times whenever they wish. What I wanted to created was a form which allowed the user to enter a quantity up to 50 in a textbox, and then press a button to print. How could this be done?

    Thanks.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Maybe this link will be helpful.

  3. #3
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Divardo,

    Have a look at my attached sample, it allows you to select the number of copies from a combo box.

    You could also have a form with all your reports in a combo or list and a combo for the number of copy.

    Result: Select the report to print from the list and then select the number of copies.

    I'm sure that you will be able to modify my code to suit your situation.

    RG: I just placed my mouse on the little marker under the number of post, mine reads OK but Yours?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I don't think Moderators are allowed to get points, which is fine with me.

  5. #5
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    RG,

    What I read was:

    RuralGuy is an unknown quantity at this stage





  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I read the same thing. It probably means I have 0 points which is neither positive or negative.

  7. #7
    Divardo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    12
    Quote Originally Posted by ansentry View Post
    Divardo,

    Have a look at my attached sample, it allows you to select the number of copies from a combo box.

    You could also have a form with all your reports in a combo or list and a combo for the number of copy.

    Result: Select the report to print from the list and then select the number of copies.

    I'm sure that you will be able to modify my code to suit your situation.

    RG: I just placed my mouse on the little marker under the number of post, mine reads OK but Yours?
    That works perfectly, thanks so much. Does anyone know how to change the printer it prints to in the vba code for this?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are you wanting to use several printers because you can have each report use whatever printer you want and it will remember the setting.

  9. #9
    Divardo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    12
    Would there be anyway to change the code in this to print the report without displaying it to the user before hand. Or if you have to display the report, hide it afterwards? Thanks

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Look up OpenReport in VBA Help. There is a Hidden argument.

  11. #11
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Try this code, I have and it works fine.



    Code:
    Private Sub cmdPrintReport_Click()
    
    
    Dim strCopyCount As String
    Dim strReport As String
    
    strReport = "RptData"
    strCopyCount = Me.cboHowMany.Column(1)
    
       Call PrintMultipleCopies(strReport, 2)
    
    End Sub
    Public Function PrintMultipleCopies(strReportName As String, _
                                        bytNumberOfCopies As Byte)
        Dim bytCounter As Byte
        For bytCounter = 1 To bytNumberOfCopies
            DoCmd.OpenReport strReportName
        Next bytCounter
    End Function
    This is not my code it came from: databasedev.co.uk

  12. #12
    Divardo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    12
    Quote Originally Posted by ansentry View Post
    Try this code, I have and it works fine.



    Code:
    Private Sub cmdPrintReport_Click()
    
    
    Dim strCopyCount As String
    Dim strReport As String
    
    strReport = "RptData"
    strCopyCount = Me.cboHowMany.Column(1)
    
       Call PrintMultipleCopies(strReport, 2)
    
    End Sub
    Public Function PrintMultipleCopies(strReportName As String, _
                                        bytNumberOfCopies As Byte)
        Dim bytCounter As Byte
        For bytCounter = 1 To bytNumberOfCopies
            DoCmd.OpenReport strReportName
        Next bytCounter
    End Function
    This is not my code it came from: databasedev.co.uk

    I can't seem to change your code to suit mine, here is mine below.

    Code:
    Private Sub cmdPrintReport_Click()
    Dim strCopyCount As String
        
        If IsNull(Me.cboHowMany) Then
         'If no selection was made from the combo box the force the user to do so.
         MsgBox "You must select number of copies from combo box", vbCritical, "No Selection"
         Me.cboHowMany.SetFocus
        
        Else
            'After a selection is made this code will run and print out the selected number of
            'copies. The code will also give you a preview of the report.
            strCopyCount = Me.cboHowMany.Column(0)
            DoCmd.OpenReport "CCVisitor", acViewPreview
            DoCmd.PrintOut , , , , strCopyCount
        
        End If
        
    End Sub

  13. #13
    Matrix's Avatar
    Matrix is offline Admin
    Windows 10 Access 2010 64bit
    Join Date
    Jan 2005
    Posts
    519
    Quote Originally Posted by RuralGuy View Post
    I don't think Moderators are allowed to get points, which is fine with me.
    I didn't notice it. Now every account will work the same way.

  14. #14
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    Delete previous code and replace with this code;

    Private Sub cmdPrintReport_Click()

    Code:
    Dim strCopyCount As Byte
    Dim strReport As String
        
            strReport = "RptData"
            strCopyCount = Me.cboHowMany.Column(1)
    
    Call PrintMultipleCopies(strReport, strCopyCount)
    End Sub

    After End Sub hit the enter key go to a new line and paste this;

    Code:
    Public Function PrintMultipleCopies(strReportName As String, _
                                        bytNumberOfCopies As Byte)
        Dim bytCounter As Byte
        For bytCounter = 1 To bytNumberOfCopies
            DoCmd.OpenReport strReportName
        Next bytCounter
    End Function
    I note that in your code your have;

    Code:
    strCopyCount = Me.cboHowMany.Column(0)
    I have;
    Code:
    strCopyCount = Me.cboHowMany.Column(1)
    Are you sure that yours is correct?

    The reason the code that I posted did not work was I posted the wrong copy of the code ... sorry my error.

    If you still can't get it to work either post a copy of your db and I or someone else will have a look at it OR post back and I will post you an updated sample.

  15. #15
    Divardo is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    12
    That works perfectly, thanks so much .

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help On Comparing Quantity in Tables
    By rochy81 in forum Access
    Replies: 2
    Last Post: 05-29-2009, 10:20 AM
  2. Return blank field depending on quantity
    By anthonyjf in forum Access
    Replies: 1
    Last Post: 04-01-2009, 08:22 AM
  3. Report Printing Error
    By gjohnson71 in forum Reports
    Replies: 4
    Last Post: 03-07-2009, 12:36 PM
  4. Printing all tabs on one form
    By sshafer1 in forum Access
    Replies: 0
    Last Post: 12-06-2007, 07:47 PM
  5. Printing Reports....
    By Danny Christie in forum Reports
    Replies: 1
    Last Post: 12-06-2006, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums