Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    51

    Question Unanswered: Subforms and Syntax

    I am trying to use a search form and search a form that contains a subform. Some of the searchable field are on the form and some on the subform. The code for the for works fine, but when I try to add code to search the subform it tells me that the form doesn't exist!

    Here's what I have in the search form for a subform field:
    Code:
    If Len(Forms!frmfilterforrecord!Field1_RegID & vbNullString) Then
    Forms!frmMyMain_Form.sfrmMySubform.Form.Filter = "[Reg ID] = " & Chr$(34) & _ Forms!frmfilterforrecord!Field1_RegID & Chr$(34)
    End If
    What am I doing wrong!!

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    The Forms collection stores a reference to all the open forms. Subforms are not considered forms, they are considered controls. I think you will want something like:

    Me.sfrmMySubform.Form.Filter = "[Reg ID] = " ...

    This assumes the code is in the form module. Otherwise the Me reference won't work.

  3. #3
    Join Date
    Nov 2004
    Posts
    51
    Thanks! I think that's what I was doing wrong. So I need to reference the subform, not by form name, but by the "object" name it has in the main form.

    Thanks Again!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •