Results 1 to 3 of 3
  1. #1
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283

    Searching a subform field from the main form

    I have a main form that has a search section based off of unbound text boxes.



    When the filter button is clicked the following executes:

    Code:
    sWhere = "1=1"
    If Not IsNull(Me.txtCode) Then sWhere = sWhere & " and Left([MAINFR_SER_NO],3)='" & Me.txtCode & "'"
    If Not IsNull(Me.txtCarrier) Then sWhere = sWhere & " and [SUB_LOC_CD]='" & Me.txtCarrier & "'"
    If Not IsNull(Me.txtMCode) Then sWhere = sWhere & " and [MKT_CD] Like '*" & Me.txtMCode & "*'"
    It works perfectly and all of the search fields are on the main form.

    I would like to add another unbound text box that searches a subform. I tried this but I get Object Required error:

    Code:
    If Not IsNull(USED_Form_Main.txtACode) Then sWhere = sWhere & " and [SUBFORM_ACCESSORY].[ACC] Like '*" & USED_Form_Main.txtACode & "*'"
    txtACode is the unbound text box on the main form and ACC is the field I would like to search on the SUBFORM_ACCESSORY subform

    Any help would be appreciated

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    use the BUILDER to get your object paths correct. Usu:
    forms!masterForm!subFormName.Form.txtBox

  3. #3
    mindbender is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2013
    Posts
    283
    Quote Originally Posted by ranman256 View Post
    use the BUILDER to get your object paths correct. Usu:
    forms!masterForm!subFormName.Form.txtBox

    I have used the follwoing:

    If Not IsNull(Me.txtACode) Then sWhere = sWhere & " and (Forms!USED_Form_Main!SUBFORM_ACCESSORY.Form!ACC) = '" & Me.txtACode & "'"

    and the main form shows as Filtered but it is just the same base records as it has when you just open the form with no filtering.

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

Similar Threads

  1. Replies: 4
    Last Post: 02-05-2016, 02:32 PM
  2. Searching by field on subform on main form
    By helen21112010 in forum Forms
    Replies: 1
    Last Post: 10-16-2012, 07:55 AM
  3. Replies: 9
    Last Post: 12-15-2010, 01:44 PM
  4. Replies: 1
    Last Post: 11-13-2010, 12:57 PM
  5. Replies: 3
    Last Post: 11-05-2010, 03:10 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