F
Frederik
Hi all,
I have two (related) forms: cds and trakcs. I have a button on the cds
form wich opens an instance of the tracks form and fills it with the
tracks of the current record/cd in the cds form. In the beginning
everything seems to work fine, but when I close the new form and try to
open another or the same tracklist from the cds form I get an
"Application-defined or object-defined error". I have no idea what's
going wrong. Somebody experienced/solved a sort-like problem? At the
end of this message, you'll find some part of my code (comments are in
dutch).
Thanks in advance,
Frederik
** start vba code **
Private Sub cmdShowTracks_Click()
On Error GoTo Err_cmdShowTracks_Click
Dim frmPopup As Form_tracklist
Dim strLinkCriteria As String
Dim strLbl As String
Dim strAlbumTitel As String
Dim i As Integer
strLbl = Me![Label]
strAlbumTitel = Me![Albumtitel]
strLinkCriteria = "SELECT * FROM tabel_tracklist WHERE [CD]=" & "'" &
strLbl & "'"
Set frmPopup = New Form_tracklist
frmPopup.RecordSource = strLinkCriteria
frmPopup.Tag = strAlbumTitel ' titel als tag toevoegen
' nagaan of de cd wel tracks heeft in de database
If frmPopup.Recordset.RecordCount = 0 Then
MsgBox "No tracks were found. The cd has not been indexed.", _
vbInformation, "CD has not been indexed"
DoCmd.Close
Exit Sub
End If
' als de tracklist al is geopend, zet de focus daar dan op en stop
' iets is nog niet in orde!
If colForms.Count > 0 Then
For i = 1 To colForms.Count
If colForms(i).Tag = strAlbumTitel Then ' foutmelding
colForms(i).SetFocus
Set frmPopup = Nothing
Exit Sub
End If
Next i
End If
frmPopup.Visible = True
frmPopup.Move 15, 15
frmPopup.Caption = "Tracklist voor " & DQ & strAlbumTitel & DQ
frmPopup.txtAlbum.ControlSource = "=DLookUp(" & DQ & "[Albumtitel]" &
DQ & "," & _
DQ & "tabel_cds" & DQ & "," & DQ & "[Label] ='" & strLbl & "'" & DQ
& ")"
frmPopup.txtAlbum.Enabled = False
frmPopup.cmdShowTracks.Enabled = False
frmPopup.SetFocus
colForms.Add frmPopup
Exit_cmdShowTracks_Click:
Exit Sub
Err_cmdShowTracks_Click:
InputBox "Error description:", "Error", Err.Description
Resume Exit_cmdShowTracks_Click
End Sub
Private Sub frmClose(f As Form)
On Error Resume Next
colForms.Remove f.hWnd & ""
Err.Clear
End Sub
** end vba code **
I have two (related) forms: cds and trakcs. I have a button on the cds
form wich opens an instance of the tracks form and fills it with the
tracks of the current record/cd in the cds form. In the beginning
everything seems to work fine, but when I close the new form and try to
open another or the same tracklist from the cds form I get an
"Application-defined or object-defined error". I have no idea what's
going wrong. Somebody experienced/solved a sort-like problem? At the
end of this message, you'll find some part of my code (comments are in
dutch).
Thanks in advance,
Frederik
** start vba code **
Private Sub cmdShowTracks_Click()
On Error GoTo Err_cmdShowTracks_Click
Dim frmPopup As Form_tracklist
Dim strLinkCriteria As String
Dim strLbl As String
Dim strAlbumTitel As String
Dim i As Integer
strLbl = Me![Label]
strAlbumTitel = Me![Albumtitel]
strLinkCriteria = "SELECT * FROM tabel_tracklist WHERE [CD]=" & "'" &
strLbl & "'"
Set frmPopup = New Form_tracklist
frmPopup.RecordSource = strLinkCriteria
frmPopup.Tag = strAlbumTitel ' titel als tag toevoegen
' nagaan of de cd wel tracks heeft in de database
If frmPopup.Recordset.RecordCount = 0 Then
MsgBox "No tracks were found. The cd has not been indexed.", _
vbInformation, "CD has not been indexed"
DoCmd.Close
Exit Sub
End If
' als de tracklist al is geopend, zet de focus daar dan op en stop
' iets is nog niet in orde!
If colForms.Count > 0 Then
For i = 1 To colForms.Count
If colForms(i).Tag = strAlbumTitel Then ' foutmelding
colForms(i).SetFocus
Set frmPopup = Nothing
Exit Sub
End If
Next i
End If
frmPopup.Visible = True
frmPopup.Move 15, 15
frmPopup.Caption = "Tracklist voor " & DQ & strAlbumTitel & DQ
frmPopup.txtAlbum.ControlSource = "=DLookUp(" & DQ & "[Albumtitel]" &
DQ & "," & _
DQ & "tabel_cds" & DQ & "," & DQ & "[Label] ='" & strLbl & "'" & DQ
& ")"
frmPopup.txtAlbum.Enabled = False
frmPopup.cmdShowTracks.Enabled = False
frmPopup.SetFocus
colForms.Add frmPopup
Exit_cmdShowTracks_Click:
Exit Sub
Err_cmdShowTracks_Click:
InputBox "Error description:", "Error", Err.Description
Resume Exit_cmdShowTracks_Click
End Sub
Private Sub frmClose(f As Form)
On Error Resume Next
colForms.Remove f.hWnd & ""
Err.Clear
End Sub
** end vba code **