As a continuation of my previous thread:
The code that works has a failure. Everytime there is a type that has no records related to it, the first row of products changes to that type. How could I avoid that?
The code I use is:
Option Compare Database
Private Sub cmdOpenRpt_Click()
On Error GoTo Err_cmdOpenRpt_Click
Dim strWhere As String
If Not IsNull(Me.cboTypeId) Then
strWhere = "[TypeId] = " & Me.cboTypeId
End If
Dim stDocName As String
stDocName = "Products"
MsgBox "strWhere: " & strWhere
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_cmdOpenRpt_Click:
Exit Sub
Err_cmdOpenRpt_Click:
Select Case Err
Case 2501
'ignore
Case Else
MsgBox Err.Description
End Select
Resume Exit_cmdOpenRpt_Click
End Sub
It works on frmByType that works with tblTypes and rptProducts that shows tblProducts. But for more reference you could also check my previous thread.
The code that works has a failure. Everytime there is a type that has no records related to it, the first row of products changes to that type. How could I avoid that?
The code I use is:
Option Compare Database
Private Sub cmdOpenRpt_Click()
On Error GoTo Err_cmdOpenRpt_Click
Dim strWhere As String
If Not IsNull(Me.cboTypeId) Then
strWhere = "[TypeId] = " & Me.cboTypeId
End If
Dim stDocName As String
stDocName = "Products"
MsgBox "strWhere: " & strWhere
DoCmd.OpenReport stDocName, acPreview, , strWhere
Exit_cmdOpenRpt_Click:
Exit Sub
Err_cmdOpenRpt_Click:
Select Case Err
Case 2501
'ignore
Case Else
MsgBox Err.Description
End Select
Resume Exit_cmdOpenRpt_Click
End Sub
It works on frmByType that works with tblTypes and rptProducts that shows tblProducts. But for more reference you could also check my previous thread.