Results 1 to 7 of 7
  1. #1
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145

    Onload Filter Question

    I'm still a noob with VBA. Heres my onLoad filter, its not working.. I'm sure its just syntax. just with Me.Filter = "[Deleted] = False" it works fine, not sure how to add "or"s

    Private Sub Form_Load()
    Me.Filter = "[Deleted] = False Or [GeographicalLocation] = 'Abq Trash/Reject' Or [GeographicalLocation] = 'Reject/Trash'"
    Me.FilterOn = True


    End Sub

  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,521
    Looks okay offhand. Are you sure the location values aren't an ID rather than the text?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145
    Yeah I checked in the database and the value stored in the fields is the text, not the ID. I dont get it. I did realize I needed to change the code to

    Private Sub Form_Load()
    Me.Filter = "[Deleted] = False Or [GeographicalLocation] <> 'Reject/Trash'"
    Me.FilterOn = True
    End Sub

    Cause I'm trying to filter out all deleted parts and parts in the trash location, and it filters out deleted parts fine, but not the ones in the trash

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Oh, change Or to And.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145
    Wow, you're right it worked.. seems weird to say And though, seems like that would filter out parts that were both deleted and in the trash location instead of either deleted or in the trash... very strange VBA stuff... but it worked! thanks!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help! When you use <> instead of = it flips the logic.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    alexandervj is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    145
    Aahh I see! Thanks again!

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

Similar Threads

  1. How can I filter a subform onLoad?
    By alexandervj in forum Access
    Replies: 1
    Last Post: 03-20-2014, 04:08 PM
  2. Onload event doesn't work for filter
    By tagteam in forum Forms
    Replies: 2
    Last Post: 02-12-2014, 11:54 AM
  3. Basic filter question... filter with like
    By Ruegen in forum Programming
    Replies: 9
    Last Post: 12-03-2013, 08:14 PM
  4. resize linked image onload
    By sconard in forum Reports
    Replies: 5
    Last Post: 09-25-2013, 11:09 AM
  5. Record Check on Form OnLoad
    By tramp82 in forum Forms
    Replies: 10
    Last Post: 10-19-2011, 07:19 PM

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