Thread: Pass Query results to Listbox
11-23-04, 18:07 #1Registered User
- 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" MyDatabase.QueryDefs.Refresh 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
11-25-04, 17:01 #2Cavalier King Charles
- Join Date
- Dec 2002
- Préverenges, Switzerland
myList.rowsource = "qryDynamic_QBF"
...of course with suitable designtime or runtime adjustments to
izycurrently using SS 2008R2