Hmmm
Are you trying to select "music" or "cd", and then display details in the "hits" in a "contineous form" (what you call a list box)?
The first part is not too hard. Since you are using only a few "tables", I suspect a value list for the control source would work best. From your description, you seemed to have worked out this aspect.
The contents displayed in the contineous form is can be controlled by changing the record source.
The real challenge is to search for "hits". I do not know your database design, but I suspect you want to check album titles, song titles, lyrics (if you have included this in your database), bands, band members, writers.
Your select statement would be complicated where you could use the key phrase LIKE.
A simplified example...
The end user enters "Green Fields" in the text search field. We then restrict the search to the "Title"...
SELECT * From Music_Table
WHERE Song_Title LIKE "*Green Fields*"
Returns...
The Green Fields of Earth
Mr. Green Fields
Now add a bit of complexity, and search album and song titles....
SELECT * From Music_Table
WHERE Song_Title LIKE "*Green Fields*" OR Album_Title LIKE "*Green Fields*"
...See where I am going with this. As you add fields to search, the complexity of the SQL statement grows.
...Moving on...
Assumptions:
- Your "table" combo box is called "SelectTable",
- The text box to accept the search sstring is called "SearchString",
- Your subform which is a contineous form is called "DisplayMusicSbFrm"
- I will guess at your field names
- You have a command button called "SearchIT".
Code for the OnClick event for "SearchIT" may look something like...
Code:
Dim strSQL as String, strQ as String, strWhere as String
Dim strTXT as String
strQ = CHR$(34) 'double quote character
If Len(Nz(Me.SearchString),"") > 0 Then
strTXT = Me.SearchString
If Len(Nz(Me.SelectTable),"") > 0 Then
strSQL = "Select * from " & Me.SelectTable
strWhere = "Album_Title Like " & strQ & "*" & strTXT & "*" & strQ
strWhere = " AND Song_Title Like " & strQ & "*" & strTXT & "*" & strQ
strSQL = strSQL & " Where " & strSQL
Me.DisplayMusicSbFrm.RecordSource = strSQL
Me.DisplayMusicSbFrm.Requery
End If
End If
Hope this gives some ideas. If you were to include bands, band members, you would have to tack on a LIKE clause for each.
I am curious. You have a Music table and CD table -- what is the difference between these? The fact that the fields are similar suggest they may be a better design to use one table for both instead of splitting the two. Although you would have to add something a field like "MediaType", this approach would simplify your code.
Richard