Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004

    Unanswered: Pass Query results to Listbox

    I am using QBF to display results in a query of multiple searches from various different combo boxes on my search form. The Query by Form is working perfectly and displaying the desired results in the query.

    The next step is to have a listbox or a subform on the main search form to display the results upon running the search rather than the results opening for reviewing in the query itself. The code I am using is shown below, can anyone give me some ideas on how to amend the code so that the results will be displayed in either a subform or list box on the main search form.

    Private Sub CmdSearchJukebox_Click()
          Dim MyDatabase As Database
          Dim MyQueryDef As QueryDef
          Dim where As Variant
          Set MyDatabase = CurrentDb()
          ' Delete the existing dynamic query; trap the error if the query does
          ' not exist.
          If ObjectExists("Queries", "qryDynamic_QBF") = True Then
            MyDatabase.QueryDefs.Delete "qryDynamic_QBF"
          End If
          ' Note the single quotation marks surrounding the text fields [Ship
          ' Country] and [CustomerID].
          ' Note that there are no type-casting characters surrounding the
          ' numeric field [EmployeeID].
          where = Null
          where = where & " AND [ArtistID]= " + Me![ArtistID]
          where = where & " AND [TrackID]= " + Me![TrackID]
          where = where & " AND [CategoryID]= " + Me![CategoryID]
          Set MyQueryDef = MyDatabase.CreateQueryDef("qryDynamic_QBF", _
            "Select * from QryDataforQBFSearch " & (" where " + Mid(where, 6) & ";"))
    Docmd.OpenQuery "QryDynamic_QBF
    End Sub

  2. #2
    Join Date
    Dec 2002
    Préverenges, Switzerland
    myList.rowsource = "qryDynamic_QBF"

    ...of course with suitable designtime or runtime adjustments to

    currently using SS 2008R2

Posting Permissions

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