Ad-hoc query build in app by user

banks

Well-known member
Joined
Sep 7, 2005
Messages
50
Programming Experience
Beginner
Hello all,

This is a toughy, for me anyway...

I am using an access97 database, with visual studio 2003..

I am creating a 'search' form so that a user can search through a set of records. Now, i will have controls on the form so that they can select the criteria for the query. These controls will be listboxes, comboboxes or date/timepickers.

At the moment i have these controls on the form, and they are pulling data from their respective tables. for example...

form load of search form
VB.NET:
    Private Sub frmSearchCAR_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim populating As dbaCAR = New dbaCAR
        populating.PopulateLists("tblSupplier", Me.lstSuppliers)
        populating.PopulateLists("tblMaterial", Me.lstMaterials)
    End Sub
this is the way the list is populated in another module
VB.NET:
    Public Sub PopulateLists(ByVal strTable As String, ByVal lstControl As ListBox)
        ds = New DataSet
        da = New OleDbDataAdapter("SELECT * FROM " + strTable, conn)
        da.Fill(ds, strTable)
        lstControl.DataSource = ds.Tables(0)
        lstControl.ValueMember = ds.Tables(0).Columns(0).ToString
        lstControl.DisplayMember = ds.Tables(0).Columns(1).ToString
        lstControl.SelectedIndex = -1
    End Sub
(i get my combobox data in the same way)

Trying to get values into a string:-
VB.NET:
        For Each i In lstSuppliers.SelectedItems
            strSuppliers = strSuppliers & i & ","
        Next

Now the real question is how do i get the selected values from each list, into a variable. Secondly, how do i get it all into a string that i can push into the database and perfrom a select query?

Any ideas/help/code/pointers will be very much apreciated.

Alex
 
Last edited:
Back
Top