Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2014
    Posts
    20

    Filter bound to Textbox for table not filtering

    Good Afternoon,

    These forums have been great for helping me learn about VBA and Access. I'm very new to access, but I'm a seasoned excel/VBA user. So, I just need a little bit of guidance.

    Access Version: 2010

    My Goal: Use a text box to specify the filter parameter for a table embedded within the form.


    My Problem: The value entered is not matched against the primary ID.
    Things I noticed: If I use the "Filter Selection" button in the "Home" section of the Access ribbon, it finds the record with the primary key. And I choose the option that reads, " Equals: 'X.1234.123456' "

    Below is the code: The first bit just calls a module. The second one is where all of the action is happening.

    Code:
    Private Sub txtFlt_PrimaryKey_AfterUpdate()
    
    Dim strSource As String
    
    Util.TableFilter
    
    End Sub
    Code:
    Public Sub TableFilter()
    
    Dim i As Integer
    Dim strList As String
    
    If IsNull(Form_Create.txtFlt_PrimaryKey.Value) Then
        strList = ""
    Else
        strList = Form_Create.txtFlt_PrimaryKey
        strList = Format(strList, Text)
    End If
    
    If strList <> "" Then
        Form_Create.qry_QueryTable.Form.Filter = "[Primary Key] " & "IN (""'" & strList & "'"")"
        Form_Create.qry_QueryTable.Form.FilterOn = True
    Else
        Form_Create.qry_QueryTable.Form.Filter = "[Primary Key] " & "IN " & "(""*"")" & ""
        Form_Create.qry_QueryTable.Form.FilterOn = True
    End If
    
    End Sub
    An example of the primary key is X.1234.123456.

    At first I thought it was the "." that might be throwing off the VBA commands, but if I use the "Selection/Filter" button; then it works. The primary key is stored, passed and processed as a text value.

    Can someone help me out?

    Thanks,
    CoffeeExplodingFromBrain
    Last edited by BrainExplodingFromCoffee; 04-05-2016 at 01:42 PM. Reason: more descriptive title

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 7 64bit Access 2007
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    Is [Primary Key] a field name? Or are you looking to do this with a primary key from that datatable?

  3. #3
    Join Date
    Apr 2014
    Posts
    20
    Hi Perceptus,

    [Primary Key] is the field name. I just want to query something like

    Code:
    SELECT * FROM Create WHERE [Create.Primary Key] IN ("x.1234.123456")
    Thanks,
    CoffeeMakesBrainExplode

  4. #4
    Join Date
    Apr 2014
    Posts
    20
    Hi Perceptus,

    I found the problem. My structure, binding, and all of the other special stuff that makes this stuff work was good. The only problem was with the way I was declaring the criteria parameter for the IN statement. I changed the code to look like this:

    Code:
    Form_Create.qry_QueryTable.Form.Filter = "[Primary Key] " & "IN (""" & strList & """)"
    Appreciate your attention. Thanks for working with me on this. Your questions helped me pin point the answer. rep++

    Thanks!
    Coffee+Brain = Brain Goo(Everywhere)

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

Similar Threads

  1. unbound textbox to bound textbox
    By thescottsman92 in forum Access
    Replies: 3
    Last Post: 08-29-2013, 02:02 AM
  2. Replies: 8
    Last Post: 04-12-2013, 08:59 PM
  3. Unbound textbox in bound form
    By Evilferret in forum Forms
    Replies: 5
    Last Post: 08-15-2012, 01:26 PM
  4. Bound textbox causes problems
    By LAazsx in forum Forms
    Replies: 8
    Last Post: 12-09-2010, 09:25 AM
  5. Report will not print a bound textbox
    By vvrt in forum Reports
    Replies: 0
    Last Post: 03-16-2006, 02:16 PM

Tags for this Thread

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