Hi All,
I have a form with 4 listboxes on it connected up to a "books' database.The four boxes are:
1)Authors (this one is a list of authors names)
2)Publishers (A list of the publishers who have published the authors books)
3)YearPublished(A list of the years in which the book was published)
4Genre (the catergory to which the book belonged.
The problem I have is that I have to click on all 4 boxes to get information up.While this works fine I would also like to be able to just click on less than the 4 boxes for info.For example if I wanted to bring up all authors,I would like to click on that authors name,or if I want to use two boxes like Authors and publishers and so on.As I said at the present I have to click on all 4 to get a result.Is there a way I can code this in so I can use the boxes individually or collectively
Does anyone have any suggestions.Many Thanks.Colin
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbSource As String
Dim ds As New DataSet
Dim tables As DataTableCollection = ds.Tables
Dim source1 As New BindingSource()
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String
Dim aa As String = authorList.Text
Dim bb As String = publisherList.Text
Dim cc As String = yearpublishedList.Text
Dim dd As String = genreList.Text
dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
dbSource = "Data Source = C:\Documents and Settings\Administrator\Desktop\Authors.accdb"
con.ConnectionString = dbProvider & dbSource
con.Open()
sql = "SELECT * FROM books WHERE author = '" & aa & "' AND publisher = '" & bb & "' AND yearpublished = '" & cc & "' AND genre = '" & dd & "' "
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Authors")
Dim view1 As New DataView(tables(0))
source1.DataSource = view1
DataGridView1.DataSource = view1
DataGridView1.Refresh()
con.Close()
End Sub