Results 1 to 6 of 6
  1. #1
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218

    Filter subform from text box on main form

    I'm trying to create a search box that searches through my subform and displays both records from that subform as well as the related records in my main form.



    I can easily create a search box that filters records from my main form however fields which need to be searched in my subform are not in my main form's record source.

    To create a search box for my main form, I created a text box and a button. I opened up the macro builder and went to apply filter, and typed this: [RoomName] Like "*" & [Forms]![frmMainRooms]![txtSearch] & "*" as my where condition.

    To try to make this work with my subform, i changed it to [forms]![frmMainRooms]![frmSubFacilityMgr]![LastName] Like "*" & [Forms]![frmMainRooms]![txtSearch] & "*"

    When I try this, it opens up a blank record. What am I doing wrong?

    Also I realize I should be doing this with VBA and not macro builder. I don't understand enough about VBA to get this done.

  2. #2
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    After more research, I believe the proper syntax is this: [Forms]![frmMainRooms]![frmSubFacilityMgr].[Form]![LastName] Like "*" & [Forms]![frmMainRooms]![txtSearch] & "*"

    I've tested this by creating a text box on my main form and using "[Forms]![frmMainRooms]![frmSubFacilityMgr].[Form]![LastName]" as the control source. That text box then displays the last name of the person in my subform. However, when I try to search for this persons last name it keeps displaying a blank form.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Haven't we already discussed this in another thread?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    Quote Originally Posted by June7 View Post
    Haven't we already discussed this in another thread?
    I don't think so. We discussed how to call a value from another form. Which is similar to this. We discussed search forms. I was given some very helpful links on how to build a search form (thanks Orange!). But actually searching a sub form from a main form, I don't think so.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,954
    Customary approach is to filter main form based on a value entered into a control on main form then the subform just tags along. I don't understand what you are trying to do.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ittechguy is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Aug 2015
    Posts
    218
    I ended up using vba. I'm making progress but it's painfully slow.

    I have a thread under programming that explains this better.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-02-2012, 07:39 PM
  2. filter main form base on subform data
    By ss3373 in forum Access
    Replies: 7
    Last Post: 06-24-2011, 09:21 PM
  3. Subform Filter based on Main Form Information
    By james.carpenter2 in forum Forms
    Replies: 0
    Last Post: 02-16-2011, 09:55 PM
  4. Replies: 1
    Last Post: 11-16-2010, 08:42 AM
  5. Replies: 7
    Last Post: 05-24-2009, 10:24 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