jet database engine cannot find object 0

adaniele

Registered User.
Local time
Today, 15:26
Joined
Jul 18, 2005
Messages
176
hi guys. here is my problem.

Info:
I have a form with several filters (14). Once this for is opened a report with all the data is opened in background. Then the user uses the filters and finally press the apply button to apply the filters to the report and reduce the records on it.

Here is the code for the apply button:
Code:
Private Sub Command18_Click()
    Dim strsql As String
    Dim intCounter As Integer
 
     'Build SQL String
     For intCounter = 1 To 14
       If Me("Filter" & intCounter) <> "" Then
            If Me("Filter" & intCounter).Tag = "effective_dt" Or Me("Filter" & intCounter).Tag = "open_dt" Then
                strsql = strsql & "[" & Me("Filter" & intCounter).Tag & "] " & " >= " & "#" & Me("Filter" & intCounter) & "#" & " And "
            End If
            If Me("Filter" & intCounter).Tag = "Teffective_dt" Then
                strsql = strsql & "[" & Me("Filter5").Tag & "] " & " <= " & "#" & Me("Filter" & intCounter) & "#" & " And "
            End If
            If Me("Filter" & intCounter).Tag = "Topen_dt" Then
                strsql = strsql & "[" & Me("Filter6").Tag & "] " & " <= " & "#" & Me("Filter" & intCounter) & "#" & " And "
            End If
            If Me("Filter" & intCounter).Tag = "change_id" Or Me("Filter" & intCounter).Tag = "priority" Or Me("Filter" & intCounter).Tag = "Dom" Or Me("Filter" & intCounter).Tag = "Intl" Or Me("Filter" & intCounter).Tag = "Tasman" Then
                strsql = strsql & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Me("Filter" & intCounter) & " And "
            End If
            If Me("Filter" & intCounter).Tag = "name" Or Me("Filter" & intCounter).Tag = "status" Or Me("Filter" & intCounter).Tag = "assignee" Or Me("Filter" & intCounter).Tag = "app_status" Then
                strsql = strsql & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
            End If
            If Me("Filter" & intCounter).Tag = "description" Then
                strsql = strsql & "[" & Me("Filter" & intCounter).Tag & "] " & " Like " & Chr(34) & "*" & Trim(Me("Filter" & intCounter)) & "*" & Chr(34) & " And "
            End If
        End If
     Next
 
     If strsql <> "" Then
        'Strip Last " And "
        strsql = left(strsql, (Len(strsql) - 5))
        'Set the Filter property
        MsgBox "before filter"
        Reports![RepFilter].Filter = strsql
        Reports![RepFilter].FilterOn = True
        MsgBox "after filter"
     End If
      '  DoCmd.OpenReport "RepFilter", A_PREVIEW
End Sub

Problem: if i remove those 2 lines (before and after filter) access shows me an error with the msg used in the title of this threat.

This form has worked for 2 years in access 97. but now i upgrade the application to access xp and i am getting this error.
any clue?

thx, max.
 
As a guess try:
Reports![RepFilter].Filter = Chr(34) & strsql & Chr(34)
 

Users who are viewing this thread

Back
Top Bottom