Results 1 to 11 of 11
  1. #1
    Join Date
    Dec 2010
    Posts
    13

    Filtering a continuous form

    Wow, I feel like I'm loosing my mind at the moment! I have a basic continuous form in Access 07. It has the following fields:
    Serial #, Part #, Model #
    I want to put combo boxes in the header to filter the form. I have a combo box for each field. I named them:
    SerialSearch, PartSearch, ModelSearch


    The combo boxes are based on tables to automatically update when a new serial, part, model # is added. So, I got this far, so now I have a continuous form with three combo boxes in the header. I can select a value from the combo boxes, but I have no idea how get these to filter the records. I would like to be able to enter values into multiple combo boxes and have it filter, or when the combo boxes are blank, I would like it to show all records. Help please!! Thank you!!

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    put the code in the events:
    Code:
    Private Sub DoFilter()
        dim fStr as string
        fstr="true "
        if trim(nz(SerialSearch,""))<>"" then fstr=fstr+ "and [serial #]='" & searialSearch & "' "
        if trim(nz(PartSearch,""))<>"" then fstr=fstr+ "and [part #]='" & PartSearch & "' "
        if trim(nz(ModelSearch,""))<>"" then fstr=fstr+ "and [Model #]='" & ModelSearch & "' "
        me.filter=fstr
        me.filteron=true
    End Sub
    Private Sub SerialSearch_after_update()
         DoFilter
    End sub
    Private Sub PartSearch_after_update()
         DoFilter
    End sub
    Private Sub ModellSearch_after_update()
         DoFilter
    End sub
    above codes works for all three fields are text. if some fields are number, please modify accordingly.

  3. #3
    Join Date
    Dec 2010
    Posts
    13
    Should I make a filter button to put the first code on? I see that the rest are on the comboboxes that I already have, but not sure where to put the first code.

  4. #4
    Join Date
    Dec 2010
    Posts
    13
    Oh nevermid, I see what you did. Thank you for your help I will try this out today!

  5. #5
    Join Date
    Dec 2010
    Posts
    13
    Okay, I tried it and the Model number search works great but the Part number and Serial number searches will not work. I can send you my database if that would help. thanks

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    sorry, I missed a space before the "and " for part # and serial #:
    Code:
    Private Sub DoFilter()
        dim fStr as string
        fstr="true "
        if trim(nz(SerialSearch,""))<>"" then fstr=fstr+ "and [serial #]='" & searialSearch & "' "
        if trim(nz(PartSearch,""))<>"" then fstr=fstr+ " and [part #]='" & PartSearch & "' "
        if trim(nz(ModelSearch,""))<>"" then fstr=fstr+ " and [Model #]='" & ModelSearch & "' "
        me.filter=fstr
        me.filteron=true
    End Sub

  7. #7
    Join Date
    Dec 2010
    Posts
    13
    Still not working, I have attached my database, if you get a chance could you please give it a look? Thank you in advance. It will open to the correct form.

  8. #8
    Join Date
    Dec 2010
    Posts
    13
    I'm assuming there is no solution to this problem?

  9. #9
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Sorry, I can not open accdb file. I use only Access 2003

  10. #10
    tyracg is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2012
    Posts
    1
    I think you just need to add a space before the first "and" also

    Quote Originally Posted by weekend00 View Post
    sorry, I missed a space before the "and " for part # and serial #:
    Code:
    Private Sub DoFilter()
        dim fStr as string
        fstr="true "
        if trim(nz(SerialSearch,""))<>"" then fstr=fstr+ "and [serial #]='" & searialSearch & "' "
        if trim(nz(PartSearch,""))<>"" then fstr=fstr+ " and [part #]='" & PartSearch & "' "
        if trim(nz(ModelSearch,""))<>"" then fstr=fstr+ " and [Model #]='" & ModelSearch & "' "
        me.filter=fstr
        me.filteron=true
    End Sub

  11. #11
    okahn is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Oct 2011
    Posts
    1
    Remove ON from the last line to leave it:
    me.filter=true

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

Similar Threads

  1. Continuous form problems
    By jclausen in forum Forms
    Replies: 12
    Last Post: 12-08-2010, 04:45 PM
  2. Replies: 1
    Last Post: 07-22-2010, 05:55 AM
  3. programming a continuous form?
    By Ferret in forum Programming
    Replies: 3
    Last Post: 05-30-2010, 04:51 PM
  4. jpg file in continuous form
    By ngocham2001 in forum Forms
    Replies: 3
    Last Post: 04-18-2010, 03:34 AM
  5. Continuous Form
    By duckie10 in forum Access
    Replies: 13
    Last Post: 06-09-2009, 11:15 AM

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