Results 1 to 4 of 4
  1. #1
    bgeorge12 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Eustis, FL
    Posts
    25

    Need help with filtering form code

    I have a form that is a data entry form. I have learned how to switch it to a filter form by using the Sort & Filter - Advanced - Filter by form. To simplify this I would like to write code (attached to a button) that will do this feature and upon closing the form it returns to data entry again. The field on the form that I want to search by is [Customer ID]. The form name is [Order Details]. Any help will be appreciated. Thanks

  2. #2
    bgeorge12 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Eustis, FL
    Posts
    25
    Can anyone please help me?

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I would strongly suggest you stay away from creating and editing filters on forms with VB Code, especially when it is much easier to control what your users see with queries that you can alter on the fly.

    That being said the code you're after is something like:

    Me.Filter = "([tablename]![fieldname]= '" & Me![lookupfield] & "')"
    Me.FilterOn = True
    For a text field
    Me.Filter = "([tablename]![fieldname]= " & Me![lookupfield] & ")"
    Me.FilterOn = True
    for a number field etc.

  4. #4
    bgeorge12 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Location
    Eustis, FL
    Posts
    25
    Thank you, thank you!!!

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

Similar Threads

  1. Filtering a continuous form
    By sbrookebounds in forum Forms
    Replies: 10
    Last Post: 08-14-2012, 09:56 AM
  2. Form Filtering
    By Kapelluschsa in forum Forms
    Replies: 5
    Last Post: 06-06-2011, 12:05 PM
  3. Query (Filtering?) in a Form
    By bobhra in forum Forms
    Replies: 2
    Last Post: 01-09-2011, 02:45 PM
  4. help with filtering code
    By ninachopper in forum Access
    Replies: 14
    Last Post: 09-09-2010, 06:16 PM
  5. filtering code
    By ninachopper in forum Access
    Replies: 2
    Last Post: 08-06-2010, 10:56 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