I don't know if this is the right place to ask for this kind of help but any guidance would be appreciated. I am a novice at Access vba by the way. I am trying to create/modify an existing Drill-Down code for my own purposes. The way it should work is after making a selection from qryCombo2, the lstAlbum field is populated. This part works fine. Now double-clicking an Album from lstAlbum should fill the lstTrack field with the appropriate tracks. Everything is fine but the dblclk part is buggy. For some reason it will only work on a field (lstAlbum) that contains 1 single word and not multiple words. Even then it acts as a Parameter based query and requests input. I do not want any parameter based pop-ups. Here is the code:
-----------------------------------------------------------
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT DISTINCT Album, Genre, Bitrate, Mode " & _
"FROM qryCombo2 WHERE Artist = '"
Private Const strSQL2 = "' ORDER by Album ASC;"
Private Const strSQL3 = "SELECT TrackTitle, TrackIndex, Bitrate, " & _
"Mode, Location FROM qryDrillDown2 WHERE Album = "
Private strSQL As String
Private Const strMsg1 = "Select an Artist from the list"
Private Const strMsg2 = "Double-click an Album to display it's associated tracks"
Private Const strMsg3 = "Track Listing for Album: "
Private Const strMsg4 = "Tracks"
Private Sub FillList()
strSQL = strSQL1 & Me!cboArtist.Value & _
strSQL2
Me!lstAlbum.RowSource = strSQL
Me!lstAlbum.Requery
Me!lblAlbum.Caption = "Albums from " & _
Me!cboArtist.Value
If Me!lstAlbum.ListCount = 0 Then
Me!lblAlbum.Caption = "No " & Me!lblAlbum.Caption
Me!lblTrack.Caption = strMsg2
End If
End Sub
Private Sub cboArtist_BeforeUpdate(Cancel As Integer)
If Me!cboArtist.Value <> "" Then
Call FillList
Else
Me!lblAlbum.Caption = strMsg1
End If
With Me!lstTrack
.RowSource = ""
.Requery
End With
Me!lblTrack.Caption = strMsg4
End Sub
Private Sub Form_Activate()
If Me!cboArtist.Value > 0 Then
Call FillList
Else
Me!lblAlbum.Caption = strMsg1
End If
With Me!lstTrack
.RowSource = ""
.Requery
End With
Me!lblTrack.Caption = strMsg4
With Me!lstAlbum
.RowSource = ""
.Requery
End With
End Sub
'Upon DoubleClick of an Album title, all Tracks for that Album are generated in the Track details chart
Private Sub lstAlbum_DblClick(Cancel As Integer)
If Me!lstAlbum.Value <> "" Then
With Me!lstTrack
strSQL = strSQL3 & Me!lstAlbum.Value & ";"
.RowSource = strSQL
.Requery
End With
Me!lblTrack.Caption = strMsg3 & Me!lstAlbum.Value
End If
End Sub
-----------------------------------------------------------
Any help would be much appreciated,
Brian
-----------------------------------------------------------
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT DISTINCT Album, Genre, Bitrate, Mode " & _
"FROM qryCombo2 WHERE Artist = '"
Private Const strSQL2 = "' ORDER by Album ASC;"
Private Const strSQL3 = "SELECT TrackTitle, TrackIndex, Bitrate, " & _
"Mode, Location FROM qryDrillDown2 WHERE Album = "
Private strSQL As String
Private Const strMsg1 = "Select an Artist from the list"
Private Const strMsg2 = "Double-click an Album to display it's associated tracks"
Private Const strMsg3 = "Track Listing for Album: "
Private Const strMsg4 = "Tracks"
Private Sub FillList()
strSQL = strSQL1 & Me!cboArtist.Value & _
strSQL2
Me!lstAlbum.RowSource = strSQL
Me!lstAlbum.Requery
Me!lblAlbum.Caption = "Albums from " & _
Me!cboArtist.Value
If Me!lstAlbum.ListCount = 0 Then
Me!lblAlbum.Caption = "No " & Me!lblAlbum.Caption
Me!lblTrack.Caption = strMsg2
End If
End Sub
Private Sub cboArtist_BeforeUpdate(Cancel As Integer)
If Me!cboArtist.Value <> "" Then
Call FillList
Else
Me!lblAlbum.Caption = strMsg1
End If
With Me!lstTrack
.RowSource = ""
.Requery
End With
Me!lblTrack.Caption = strMsg4
End Sub
Private Sub Form_Activate()
If Me!cboArtist.Value > 0 Then
Call FillList
Else
Me!lblAlbum.Caption = strMsg1
End If
With Me!lstTrack
.RowSource = ""
.Requery
End With
Me!lblTrack.Caption = strMsg4
With Me!lstAlbum
.RowSource = ""
.Requery
End With
End Sub
'Upon DoubleClick of an Album title, all Tracks for that Album are generated in the Track details chart
Private Sub lstAlbum_DblClick(Cancel As Integer)
If Me!lstAlbum.Value <> "" Then
With Me!lstTrack
strSQL = strSQL3 & Me!lstAlbum.Value & ";"
.RowSource = strSQL
.Requery
End With
Me!lblTrack.Caption = strMsg3 & Me!lstAlbum.Value
End If
End Sub
-----------------------------------------------------------
Any help would be much appreciated,
Brian