D
Debbie
I've copied a form filter that I want to use with a report. I replaced the
names of the report I want it to filter only which works except it will ask
for a company name which is not part of my report. I can't find where it may
be looking for this particular field. This only happens when I select my
"Select Filter" button so I have a feeling there is a problem there but can't
figure it out. The debug comes up with the arrow pointing to
Reports![System Sales Forecast].Filter = strSQL
Reports![System Sales Forecast].FilterOn = True
Below is what I did:
Option Compare Database
Option Explicit
Private Sub Command28_Click()
Dim strSQL As String, intCounter As Integer
'Build SQL String
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " =
" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
'Strip Last " And "
strSQL = Left(strSQL, (Len(strSQL) - 5))
'Set the Filter property
Reports![System Sales Forecast].Filter = strSQL
Reports![System Sales Forecast].FilterOn = True
End If
End Sub
Private Sub Command29_Click()
Dim intCouter As Integer
For intCouter = 1 To 5
Me("Filter" & intCouter) = ""
Next
End Sub
Private Sub Command30_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Private Sub Form_Close()
DoCmd.Close acReport, "System Sales Forecast Report"
DoCmd.Restore
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "System Sales Forecast Report", A_PREVIEW
DoCmd.Maximize
End Sub
names of the report I want it to filter only which works except it will ask
for a company name which is not part of my report. I can't find where it may
be looking for this particular field. This only happens when I select my
"Select Filter" button so I have a feeling there is a problem there but can't
figure it out. The debug comes up with the arrow pointing to
Reports![System Sales Forecast].Filter = strSQL
Reports![System Sales Forecast].FilterOn = True
Below is what I did:
Option Compare Database
Option Explicit
Private Sub Command28_Click()
Dim strSQL As String, intCounter As Integer
'Build SQL String
For intCounter = 1 To 5
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " =
" & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <> "" Then
'Strip Last " And "
strSQL = Left(strSQL, (Len(strSQL) - 5))
'Set the Filter property
Reports![System Sales Forecast].Filter = strSQL
Reports![System Sales Forecast].FilterOn = True
End If
End Sub
Private Sub Command29_Click()
Dim intCouter As Integer
For intCouter = 1 To 5
Me("Filter" & intCouter) = ""
Next
End Sub
Private Sub Command30_Click()
DoCmd.Close acForm, Me.Form.Name
End Sub
Private Sub Form_Close()
DoCmd.Close acReport, "System Sales Forecast Report"
DoCmd.Restore
End Sub
Private Sub Form_Open(Cancel As Integer)
DoCmd.OpenReport "System Sales Forecast Report", A_PREVIEW
DoCmd.Maximize
End Sub