Error message on opening a report

swills

Registered User.
Local time
Today, 19:22
Joined
Nov 13, 2006
Messages
25
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
 
Sorry i should have explained it better, basically the 3 combo boxes need to be correct for the report to display properly. so for example is release 3.4.2.1 is selected then only certain databases can be selected etc

If they do not match then a report is shown but it is just empty. is there a way to.....
once you have selected data in the first combo box then the two other combo boxes only display data that matches in the table?
 

Users who are viewing this thread

Back
Top Bottom