lostwithaccess
Registered User.
- Local time
- Today, 09:24
- Joined
- Apr 12, 2011
- Messages
- 69
Hi everyone,
I am having a few problems with a report which is filtered by a form which I have been unable to find a solution for.
My report has an On Close event to open my main menu form, but this is being triggered by my filter command, ie- applying the filter seems to close and reopen the report, with the 'close' bringing up the main menu. Does anyone know a way to stop this?
My filter code is:
Option Compare Database
Private Sub cmdClose_Click()
DoCmd.Close acForm, "frmReportFilter"
End Sub
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click
Dim strSQL As String
Dim stDocName As String
stDocName = "rptInstitutions"
If Nz(Me.cboCountry, "") <> "" Then
strSQL = "txtCountryName='" & Me.cboCountry & "' AND "
End If
If Nz(Me.cboInstitute, "") <> "" Then
strSQL = strSQL & "txtInstitutionName='" & Me.cboInstitute & "' AND "
End If
If Nz(Me.cboLastName, "") <> "" Then
strSQL = strSQL & "txtLastName='" & Me.cboLastName & "' AND "
End If
'Strip Last " And "
If strSQL <> "" Then
strSQL = Left(strSQL, (Len(strSQL) - 5))
Debug.Print strSQL
'Set the Filter property
DoCmd.OpenReport stDocName, acPreview
Reports![rptInstitutions].Filter = strSQL
Reports![rptInstitutions].FilterOn = True
Else
MsgBox "No criteria specified, opening the report unfiltered"
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdFilter_Click:
Exit Sub
Err_cmdFilter_Click:
MsgBox Err.Description
Resume Exit_cmdFilter_Click
End Sub
My report code is:
Option Compare Database
Private Sub cmdReopenFilter_Click()
DoCmd.OpenForm "frmReportFilter"
End Sub
Private Sub Report_Close()
DoCmd.OpenForm "Menu", acNormal
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmReportFilter"
End Sub
Many thanks
I am having a few problems with a report which is filtered by a form which I have been unable to find a solution for.
My report has an On Close event to open my main menu form, but this is being triggered by my filter command, ie- applying the filter seems to close and reopen the report, with the 'close' bringing up the main menu. Does anyone know a way to stop this?
My filter code is:
Option Compare Database
Private Sub cmdClose_Click()
DoCmd.Close acForm, "frmReportFilter"
End Sub
Private Sub cmdFilter_Click()
On Error GoTo Err_cmdFilter_Click
Dim strSQL As String
Dim stDocName As String
stDocName = "rptInstitutions"
If Nz(Me.cboCountry, "") <> "" Then
strSQL = "txtCountryName='" & Me.cboCountry & "' AND "
End If
If Nz(Me.cboInstitute, "") <> "" Then
strSQL = strSQL & "txtInstitutionName='" & Me.cboInstitute & "' AND "
End If
If Nz(Me.cboLastName, "") <> "" Then
strSQL = strSQL & "txtLastName='" & Me.cboLastName & "' AND "
End If
'Strip Last " And "
If strSQL <> "" Then
strSQL = Left(strSQL, (Len(strSQL) - 5))
Debug.Print strSQL
'Set the Filter property
DoCmd.OpenReport stDocName, acPreview
Reports![rptInstitutions].Filter = strSQL
Reports![rptInstitutions].FilterOn = True
Else
MsgBox "No criteria specified, opening the report unfiltered"
DoCmd.OpenReport stDocName, acPreview
End If
Exit_cmdFilter_Click:
Exit Sub
Err_cmdFilter_Click:
MsgBox Err.Description
Resume Exit_cmdFilter_Click
End Sub
My report code is:
Option Compare Database
Private Sub cmdReopenFilter_Click()
DoCmd.OpenForm "frmReportFilter"
End Sub
Private Sub Report_Close()
DoCmd.OpenForm "Menu", acNormal
End Sub
Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "frmReportFilter"
End Sub
Many thanks