Results 1 to 2 of 2
  1. #1
    ilikebirds is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    14

    Access 2010 Works 2007 Error Me.Browse.Form.Filter = strWhere

    So I have the following search code:
    Code:
         ' If App To
        If IsDate(Me.TermTo) Then
            ' Add it to the predicate - exact
            strWhere = strWhere & " AND " & "MainDB.[Case Terminated Date] <= " & GetDateFilter(Me.TermTo)
        ElseIf Nz(Me.TermTo) <> "" Then
            strError = cInvalidDateError
        End If
        If strError <> "" Then
            MsgBox strError
        Else
            'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
            If Not Me.FormFooter.Visible Then
                Me.FormFooter.Visible = True
                DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
            End If
            Me.Browse.Form.Filter = strWhere
            Me.Browse.Form.FilterOn = True
        End If
    End Sub
    In 2010 Access the search works fine! In Access 2007 I get an error at the Line Me.Browse.Form.Filter=Strwhere


    and mouseover reveals: The expression you entered refers to an object that is not...

    Any Ideas?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Comments inline:

    Code:
        ' If App To
        If IsDate(Me.TermTo) Then
            ' Add it to the predicate - exact
    
            'does the function GetDateFilter() add date delimiters?
    
            strWhere = strWhere & " AND " & "MainDB.[Case Terminated Date] <= " & GetDateFilter(Me.TermTo)
    ' is there ever a chance that the WHERE string will BEGIN with " AND " ???
    
        ElseIf Nz(Me.TermTo) <> "" Then
            strError = cInvalidDateError
        End If
        If strError <> "" Then
            MsgBox strError
        Else
            'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
            If Not Me.FormFooter.Visible Then
                Me.FormFooter.Visible = True
                DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
            End If
    
    'I have never see this usage of "Browse"
    'I would use:
    
            Me.Filter = strWhere
            Me.FilterOn = True
    
    '        Me.Browse.Form.Filter = strWhere
    '        Me.Browse.Form.FilterOn = True
        End If
    End Sub
    Also, using spaces in Access object names is not considered a good thing to do. It will cause you headaches in queries, forms and reports.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-26-2012, 10:02 PM
  2. Replies: 3
    Last Post: 05-30-2012, 01:43 PM
  3. Replies: 3
    Last Post: 03-15-2012, 03:42 PM
  4. Replies: 6
    Last Post: 02-18-2012, 07:20 AM
  5. Form works, Subform gets error
    By jlclark4 in forum Forms
    Replies: 9
    Last Post: 01-03-2011, 09:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums