Hi all,
this is probably quite simple but im a having a mind block doing this.
I have a form with 3 combo boxes in and depending on these selections a report is shown with a graph on it. this works fine.
However if these selctions are wrong i want an error message to be shown and the report to not open. How do i do this?
my current code on the form is:
Private Sub Filter_Click()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
On Error GoTo Err_Filter_Click
strSQL = "SELECT tblDetails.* " & _
"FROM tblDetails " & _
"WHERE tblDetails.[Run Date]='" & Me.cboDate.Value & "' And tblDetails.[Database Name]='" & Me.cboDB.Value & "' And tblDetails.Release='" & Me.cboRelease.Value & "'"
Set qdf = CurrentDb.QueryDefs("qryTemp")
qdf.SQL = strSQL
qdf.Close
DoCmd.OpenReport "rptMem", acPreview
Set qdf = Nothing
Set db = Nothing
Exit_Filter_Click:
Exit Sub
Err_Filter_Click:
MsgBox Err.Description
Resume Exit_Filter_Click
End Sub
Thanks in advance
this is probably quite simple but im a having a mind block doing this.
I have a form with 3 combo boxes in and depending on these selections a report is shown with a graph on it. this works fine.
However if these selctions are wrong i want an error message to be shown and the report to not open. How do i do this?
my current code on the form is:
Private Sub Filter_Click()
Dim db As Database
Dim qdf As QueryDef
Dim strSQL As String
On Error GoTo Err_Filter_Click
strSQL = "SELECT tblDetails.* " & _
"FROM tblDetails " & _
"WHERE tblDetails.[Run Date]='" & Me.cboDate.Value & "' And tblDetails.[Database Name]='" & Me.cboDB.Value & "' And tblDetails.Release='" & Me.cboRelease.Value & "'"
Set qdf = CurrentDb.QueryDefs("qryTemp")
qdf.SQL = strSQL
qdf.Close
DoCmd.OpenReport "rptMem", acPreview
Set qdf = Nothing
Set db = Nothing
Exit_Filter_Click:
Exit Sub
Err_Filter_Click:
MsgBox Err.Description
Resume Exit_Filter_Click
End Sub
Thanks in advance