Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Print ONE Invoice!

    I'm trying to make a report, which prints out invoices, print just ONE invoice. I have a "Print Invoice" button on my Student Form and I want it to just print that student's invoice NOT every invoice. How do I do that? I'm so confused! <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Thanks for the help again, Rupert. I put the code in, but now I can't get it to print anything. What did I do wrong? Am I suppose to replace all of the code that is there with your code?

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Newbury, Berkshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    You need to change these two lines.

    strDocName = "rpt_PrnOrders"
    strFilter = "tbl_Orders.OrderID = Forms!frm_Take_Orders!OrderID"


    Peplace "rpt_PrnOrders" with the name of your report


    Your report should be based on a table or query. Replace - tbl_Orders.OrderID

  4. #4
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Look at Northwind.mdb or Nwind.mdb that comes with Access.
    Go to Orders Form in design view. See code for the Print Invoice Button.

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Okay, I tried it again, Rupert. I got it to print, but now it asks for a Parameter value. What is that? And it still prints all of my invoices. Aaaaarrrggghhh!!!

  6. #6
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Hi Jennifer:
    Can you post your code here and we can take a look at it <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Okay, here's all the code that is showing. I don't know much about Visual Basic.

    Sub LastName_AfterUpdate()
    ' Find the record that matches the control.
    Me.RecordsetClone.FindFirst "[StudID] = '" & Me![LastName] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub

    Sub Combo33_AfterUpdate()
    ' Find the record that matches the control.
    Me.RecordsetClone.FindFirst "[StudID] = '" & Me![Combo33] & "'"
    Me.Bookmark = Me.RecordsetClone.Bookmark
    End Sub

    Private Sub Cmd_Print_Current_Rec_Click()
    On Error GoTo Err_Cmd_Print_Current_Rec_Click

    Dim strDocName As String
    Dim strFilter As String

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 'Save record

    strDocName = "Invoice"
    strFilter = "tbl_Invoices.InvID = Forms!frm_Student!InvID"


    DoCmd.OpenReport strDocName, acViewNormal, , strFilter

    Exit_Cmd_Print_Current_Rec_Click:
    Exit Sub

    Err_Cmd_Print_Current_Rec_Click:
    MsgBox Err.Description
    Resume Exit_Cmd_Print_Current_Rec_Click

    End Sub


    I don't know what the other two SUBs are, though 'cause like I said, I don't know much of anything about VBA. I hope you can help.

    Jennifer

  8. #8
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Not knowing exactly how your form and report are structured, I'm assuming the form contains a control [InvID] and can be linked to the "Invoice" report using that unique identifier. If not you might try [StudID] <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    <hr> Dim stDocName As String
    Dim stLinkCriteria As String

    stLinkCriteria = "[InvID]=" & Me![InvID]
    stDocName = "Invoice"

    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria<hr>

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Where do I enter that code you gave me? I told you I'm pretty <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15> when it comes to VBA.

    Jennifer

  10. #10
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Sorry Jennifer, just replace this whole procedure:
    <hr>Private Sub Cmd_Print_Current_Rec_Click()
    On Error GoTo Err_Cmd_Print_Current_Rec_Click

    Dim strDocName As String
    Dim strFilter As String

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 'Save record

    strDocName = "Invoice"
    strFilter = "tbl_Invoices.InvID = Forms!frm_Student!InvID"


    DoCmd.OpenReport strDocName, acViewNormal, , strFilter

    Exit_Cmd_Print_Current_Rec_Click:
    Exit Sub

    Err_Cmd_Print_Current_Rec_Click:
    MsgBox Err.Description
    Resume Exit_Cmd_Print_Current_Rec_Click

    End Sub<hr>
    With this ....

    Private Sub Cmd_Print_Current_Rec_Click()
    On Error GoTo Err_Cmd_Print_Current_Rec_Click

    Dim strDocName As String
    Dim stLinkCriteria As String

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70 'Save record

    strDocName = "Invoice"
    stLinkCriteria = "[InvID]=" & Me![InvID]


    DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

    Exit_Cmd_Print_Current_Rec_Click:
    Exit Sub

    Err_Cmd_Print_Current_Rec_Click:
    MsgBox Err.Description
    Resume Exit_Cmd_Print_Current_Rec_Click

    End Sub

    Then cross your fingers . <img src=/S/wink.gif border=0 alt=wink width=15 height=15>

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Ummmmmm....I tried it, but it didn't work. It said that it can't find InvID. I have that on my form, but InvID is actually on the form in a subform. Does that make any difference?

    Jennifer

  12. #12
    4 Star Lounger
    Join Date
    Dec 2000
    Location
    London, Ontario, Canada
    Posts
    437
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    Okay .. try changing this line
    <hr>stLinkCriteria = "[InvID]=" & Forms!frm_Student!InvID<hr>
    Crossing my fingers ...

  13. #13
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    I tried it and it gave me a message that it couldn't find my "frm_Student", so I changed it to just "Student" because that is what it is called under my forms tab. Then it gave me the same message as before that it couldn't find InvID.

    Jennifer <img src=/S/dizzy.gif border=0 alt=dizzy width=15 height=15>

  14. #14
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    284
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    I found something about using a "CurrentRecord" phrase in the coding, but it doesn't really show enough info for me to really know how to use it properly. Have you used this?

    Jennifer

  15. #15
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Youngstown, Ohio, USA
    Posts
    705
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Print ONE Invoice!

    I created a button on the form, with the command to print the current form only. The button's display attribute was set to display only, so that it doesn't get printed out with the rest of the form.

    This is the VBA code behind the button (On Click [Event Procedure]):

    <pre>Private Sub PrintCurrentRecord_Click()
    On Error GoTo Err_PrintCurrentRecord_Click

    DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
    DoCmd.PrintOut acSelection

    Exit_PrintCurrentRecord_Click:
    Exit Sub

    Err_PrintCurrentRecord_Click:
    MsgBox Err.Description
    Resume Exit_PrintCurrentRecord_Click
    End Sub
    </pre>


    Fortunately, Access will write all of this for you. When you create the button, select Form Operations / Print Current Form for Category and Action. Place the button where it will not interfere with the remainder of the form, but will be convenient to activate.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •