Results 1 to 7 of 7
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Filter expression

    In the following segment of code within a General Module, I can't get the Requery to take effect. What's wrong?

    Here's the filter: Click image for larger version. 

Name:	000.jpg 
Views:	12 
Size:	3.8 KB 
ID:	46103

    Code:
    snip
    
    Dim dteGAPuse As Date
     
    On Error GoTo Handle2474
     
    lngID = Forms("frmLibrary").Form.WorksID           'Get record ID from our host (not a parent per se') form
    
    
    If Screen.ActiveControl.Name = "tbGAPuse" Then     'Error 2474 if we're not on a control
        dteGAPuse = Nz(DLookup("GAPuse", "QLibrary", "WorksID = " & lngID))
        If dteGAPuse = 0 Then Exit Function
        Forms("frmLibrary").Form.Filter = "GAPuse = " & "#" & dteGAPuse & "#"
        
        MsgBox Forms("frmLibrary").Form.Filter
        Forms("frmLibrary").Form.Requery
        Exit Function
    End If
    
    
    Skip2474:
    
    
    ReDim strURL(30)
    
    snip


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Typically you need to set FilterOn.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I tried that to begin thinking I wouldn't even need the Requery but it failed, and it still does.
    Click image for larger version. 

Name:	001.jpg 
Views:	11 
Size:	168.1 KB 
ID:	46104

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Good Grief! This is what I had started with, but neglected to tell Access the property "Value" I wanted............. I'm not loosing it, I've already lost it!

    Code:
    Dim strFileName As String
    Dim strSrch As String
    Dim strSrchSufx As String
    Dim dteGAPuse As Date
     
    On Error GoTo Handle2474
     
    lngID = Forms("frmLibrary").Form.WorksID           'Get record ID from our host (not a parent per se') form
    
    
    If Screen.ActiveControl.Name = "tbGAPuse" Then     'Error 2474 if we're not on a control
        dteGAPuse = Nz(DLookup("GAPuse", "QLibrary", "WorksID = " & lngID))
        If dteGAPuse = 0 Then Exit Function
        Forms("frmLibrary").Form.Filter = "GAPuse = " & "#" & dteGAPuse & "#"
        Forms("frmLibrary").Form.FilterOn = True
        Exit Function
    End If
    
    
    Skip2474:
    
    
    ReDim strURL(30)

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you got it sorted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Is there a need to requery if you just set a filter?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Quote Originally Posted by Welshgasman View Post
    Is there a need to requery if you just set a filter?
    In my experience no, and Bill already took it out of his code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 02-21-2016, 05:44 PM
  2. Replies: 2
    Last Post: 03-22-2015, 11:16 AM
  3. Replies: 4
    Last Post: 07-11-2014, 05:51 AM
  4. Replies: 6
    Last Post: 05-05-2014, 10:51 PM
  5. Syntax Error in Query Expression on filter
    By alaric01 in forum Forms
    Replies: 1
    Last Post: 10-14-2010, 07:23 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