Results 1 to 3 of 3
  1. #1
    Join Date
    May 2006

    Unanswered: using listboxes to print a report

    Hey guys,

    I have a question, I have a little database and want to have an option where i can press a button to view all my Orders.

    The orders are uniquely identified by its OrderID.

    I want to Press a button and populate a list box with all my orders, from that list i want to press a button that will print off that order. Can this be achieved? if so can someone point me in the right direction.



  2. #2
    Join Date
    May 2005
    Here's a good tutorial to get you started on populating the list box. This post in the FAQ can show you how to do stuff with selected items in a listbox.
    Me.Geek = True

  3. #3
    Join Date
    Mar 2009
    Provided Answers: 15
    1) Set the RowSource property of the listbox to something like:

    SELECT OrderID, ... FROM Orders
    You can add an ORDER BY clause to have it sorted and/or a WHERE clause to limit the list to certain records. Ex:

    SELECT OrderID, OrderCustomer, OrderDate FROM Orders WHERE OrderPaid = False ORDER BY OrderDate;
    Add a button on the form and in the OnClick event add some code like this:

    Private Sub Button_PrintOrder_Click()
        If Not IsNull(Me.List_Orders.Value) Then
            DoCmd.OpenReport "Report_Order", acViewNormal, , "OrderID = " & Me.List_Orders.Value, acWindowNormal
        End If
    End Sub
    This supposes that you have a report named Report_Order and that its RecordSource property include the OrderID field from the Orders table or query.

    Have a nice day!

Posting Permissions

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