Results 1 to 9 of 9
  1. #1
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91

    Dtata not being filtered

    I have a text box on Form 2 that needs to filter data on Form 3. I typed in the following on Form 3, and I did try typing the code with private sub txtexample_AfterUpdate() on Form 2. They both did nothing.


    Private Sub Form_LOad()
    If Len(Form_002_Criteria.TxtExample & vbNullString) > 0
    Then Me.Filter = "ExpMin <= " & Form_002_Criteria.TxtExample & " AND ExpMax >= " & Form_002_Criteria.TxtExample
    Me.FilterOn = True
    Else
    Me.Filter = ""


    Me.FilterOn = False
    End If
    End Sub

    In the query for the list box, I added ExpMin and ExpMax fields unchecked with criteria stating Forms![002_Criteria]!TxtExample to filter the data needs to be shown base on Min and Max values.

  2. #2
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    Code:
    Private Sub Form_LOad()
     If Len(Form_002_Criteria.TxtExample & vbNullString) > 0 Then 
        Me.Filter = "ExpMin <= " & Form_002_Criteria.TxtExample & " AND ExpMax >= " & Form_002_Criteria.TxtExample 
        debug.print me.filter    
    Me.FilterOn = True 
    Else 
        Me.Filter = "" 
        Me.FilterOn = False 
    End If
    End Sub
    The debug.print will show you what the query contains.

    In the query for the list box, I added ExpMin and ExpMax fields unchecked with criteria stating Forms![002_Criteria]!TxtExp to filter the data needs to be shown base on Min and Max values.
    Where is this list box? How does it tie in with your problem?

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    why didnt you put the filter for form 3 ON form 3?

  4. #4
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by davegri View Post
    Code:
    Private Sub Form_LOad()
     If Len(Form_002_Criteria.TxtExample & vbNullString) > 0 Then 
        Me.Filter = "ExpMin <= " & Form_002_Criteria.TxtExample & " AND ExpMax >= " & Form_002_Criteria.TxtExample 
        debug.print me.filter    
    Me.FilterOn = True 
    Else 
        Me.Filter = "" 
        Me.FilterOn = False 
    End If
    End Sub
    The debug.print will show you what the query contains.


    Where is this list box? How does it tie in with your problem?
    The list box is on form 3, this ties into the problem because I have several fields of species that needs to be filter when you enter a value. You don't want to scroll down several thousand data looking for species that live at certain climate conditions. For example This will bring up species that live at min or max of 50 elevation.

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    because I have several fields of species that needs to be filter when you enter a value
    Another set of criteria in addition to the first post? All too confusing. I don't understand your setup at all, and can't help at this point.

  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
    You must not be a PRO davegri.

    ryder, not sure why you started a new thread, but if you're trying to filter a listbox you'd have to change its row source. The code you're using filters the form's record source, not a listbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I don't want to get involved because I still don't understand - but would love to know how something can be less than or equal to something else AND more than or equal to it at the same time. Might as well use something=something else

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    If I read correctly, there are 2 different fields in the table. Filtering for records where the given value on the form is >= a minimum value and <= a maximum value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    qwerty is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    91
    Quote Originally Posted by pbaldy View Post
    If I read correctly, there are 2 different fields in the table. Filtering for records where the given value on the form is >= a minimum value and <= a maximum value.
    Yes that is correct. There a text box on page (2) is to enter the value you want displayed on page (3). I have zero coding written in vba. For list boxes I have it pointed to a query for Field1, Field2, Field3, and Field4. The txt suppose to filter the list box data based on

    The text box suppose work for example, say there a value of 15 to 80.
    if someone enters 20 is 20 >= 15? T or 20 <= 80? T
    If someone enters 100 is 100 >= 15? T or is 100 <= 80? F

    Then it will show all the data in those ranges. I was going to put Field1, Field2, Field3, Field4 all in one list box, but the problem working with science data there is more than ond unique name attached to different species. So the results will be missing information. Right now they are separated in their own list box and all unique values show.

    Thank you pbadly...I am new to access and really try to learn. I am even really to pay for someone to do gotomeeting fo show what I am doing, and guide me in the right direction. I even offered to pay in one post, but for some reason people want me to post information. It's much easier to explain over gotomeeting or skype.

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

Similar Threads

  1. Filtered Records Wont Stay Filtered
    By ortizimo in forum Access
    Replies: 4
    Last Post: 11-29-2017, 07:08 PM
  2. Filtered records
    By hinchi1 in forum Access
    Replies: 42
    Last Post: 11-29-2017, 03:54 AM
  3. Filtered Report from filtered datasheet form
    By gemadan96 in forum Reports
    Replies: 7
    Last Post: 01-03-2014, 05:12 PM
  4. Replies: 3
    Last Post: 11-06-2012, 03:25 PM
  5. Filtered query look up
    By FuzzyLogician in forum Access
    Replies: 2
    Last Post: 02-09-2012, 11:00 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