Results 1 to 7 of 7
  1. #1
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40

    need to filter a column in a subform

    Hi, I have a form where I scan in a number into a Text Box on the Form, and have a table of values as a subform on the form. I am hoping that I can write a command that will filter the records in the subform table based on the value scanned into the text box. Seems like a DoCmd.SetFilter should do this, but I'm not apparently close on the format. I even tried doing this where it opens the source table separately and applies the SetFilter, but I either get a popup window asking for the value in the Text box that I did a SetFocus on, or returning a blank table with everything filtered. Any ideas greatly appreciated!

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Assuming that your main form is bound to a table and the subform to it's "child", you would link them based on the key fields. On the appropriate event of the text box, such as AfterUpdate, you would do a
    Me.Filter="Key=" & Me!textbox/column(x)
    Me.FilterOn=True
    Me.Requery
    That should provide the filtered set of records in your subform.

  3. #3
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    Hi, no such luck. Tried working with the filter but not seeing any results. I've attached the forms so you can see what I'm working with. Basically, Text9 on the form is where the Pallet Number (PalletNr) is entered, and would like it to sort the subform Table (Cont_to_Warehouse subform) based on the value in Text9. I could of course use the normal table filtering buttons in the subform, but trying to simplify things for operators who have no computer skills, so trying to make it as close to "1 click" as possible.
    Attached Files Attached Files

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    There is something wrong with this database! It is a very simple thing that you are trying to do yet I couldn't figure out why it was ignoring me! I ended up recreating everything, now it works.

    Basically, in the AfterUpdate event of the text field I requery the subform. I removed the need for filtering by creating a query for the record source for the subform which specifies that is must match the text field.
    Attached Files Attached Files

  5. #5
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    Not sure I follow, other than the filter part of it, seems to work for me. But not following the set up you sent, I don't seem to be able to get it to filter results based on the PalletNr field.

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    I didn't use the button. I put in a requery in the AfterUpdate event, so when you enter a pallet nbr and hit enter the subform will be requerried. I wonder if there isn't a problem with your installation or something, that database you sent me wouldn't work properly at all.

  7. #7
    gregu710 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2012
    Location
    Frederick, CO (near Longmont and Boulder)
    Posts
    40
    Might be something with the setup. I tried it as you described, but no luck. I'll pin down our IT guy tomorrow and have a look-see, since he knows Access as well. Maybe he can figure out what I'm not.

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

Similar Threads

  1. Filter subform
    By DCV0204 in forum Forms
    Replies: 1
    Last Post: 12-01-2011, 10:37 AM
  2. Pass Subform filter to subform in report
    By camftm in forum Programming
    Replies: 16
    Last Post: 07-19-2011, 07:12 AM
  3. filter report by query row and column
    By usmcgrunt in forum Access
    Replies: 4
    Last Post: 04-13-2011, 06:52 PM
  4. Fixed column widths in SubForm
    By nyteowl in forum Access
    Replies: 4
    Last Post: 10-15-2010, 02:00 PM
  5. Filter form by column
    By smikkelsen in forum Forms
    Replies: 10
    Last Post: 04-27-2010, 10:46 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