Hello!
I am using a form to call up a report, and sometimes there are no records that fit the criteria specified in the form, (TEAM and YEAR) and the report loads but the fields contain #ERROR in them (obviously because no records were retrieved.) What I would like to do is have a message box state that there are no records to be found, or something like that.
Here is the code I currently have attached to the PRINT button: (edited down for space)
Case 4 ' List Box 4 selected,
'Need YEAR, and TEAM
If (cmbYear.Value = ""
Or IsNull(cmbYear.Value) Then
strMsg = "You must select a Year from the dropdown list!"
intResponse = MsgBox(strMsg, vbOKOnly, "ERROR!"
cmbYear.SetFocus
End
ElseIf (cmbTeamName.Value = ""
Or IsNull(cmbTeamName.Value) Then
strMsg = "You must select a Team from the dropdown list!"
intResponse = MsgBox(strMsg, vbOKOnly, "ERROR!"
cmbTeamName.SetFocus
End
Else
DoCmd.OpenReport "RptYTDTeamSummary", ReportDest, , "Forms![PrintForm]![CmbTeamName] = [MainTbl]![TeamID] and Forms![PrintForm]![CmbYear] = [MainTbl]![AuditYear]"
End If
This is for ACCESS 97. Thanks in advance!
Mr. K
I am using a form to call up a report, and sometimes there are no records that fit the criteria specified in the form, (TEAM and YEAR) and the report loads but the fields contain #ERROR in them (obviously because no records were retrieved.) What I would like to do is have a message box state that there are no records to be found, or something like that.
Here is the code I currently have attached to the PRINT button: (edited down for space)
Case 4 ' List Box 4 selected,
'Need YEAR, and TEAM
If (cmbYear.Value = ""
strMsg = "You must select a Year from the dropdown list!"
intResponse = MsgBox(strMsg, vbOKOnly, "ERROR!"
cmbYear.SetFocus
End
ElseIf (cmbTeamName.Value = ""
strMsg = "You must select a Team from the dropdown list!"
intResponse = MsgBox(strMsg, vbOKOnly, "ERROR!"
cmbTeamName.SetFocus
End
Else
DoCmd.OpenReport "RptYTDTeamSummary", ReportDest, , "Forms![PrintForm]![CmbTeamName] = [MainTbl]![TeamID] and Forms![PrintForm]![CmbYear] = [MainTbl]![AuditYear]"
End If
This is for ACCESS 97. Thanks in advance!
Mr. K