Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2006
    Posts
    3

    Question Unanswered: Filter Subform Data using combo boxes

    Here's what i have/need. Any help is greatly appreciated.

    1 form (form_SearchProducts) containing:

    3 combo boxes (cboCustomerName, cboProjectNumber, cboModel Number)
    1 subform (subform_ShowProducts which is linked to table_Products)

    I want to be able to select a Customer Name from cboCustomerName, then filter subform_ShowProducts to display only the Products whose CustomerName field matches the selected CustomerName from cboCustomerName.

    here's my code....

    Private Sub cboCustomerName_AfterUpdate()

    Dim sCustomerName As String

    sCustomerName = cboCustomerName

    Forms!form_SearchProducts!subform_ShowProducts.Fil ter = "CustomerName = 'sCustomerName'"
    Forms!form_SearchProducts!subform_ShowProducts.Fil terOn = True

    End Sub


    I get an error '438'. Object does not support this object or method.
    Hopefully someone can give me some insight.


    It would also be nice if after a Customer Name is selected, the cboProjectNumber and cboModelNumber are also filtered for the selected Customer Name. I haven't started this yet, 1 thing at a time.

    Thanks in advance to all.

  2. #2
    Join Date
    Feb 2004
    Posts
    25

    Smile Quotes need tweaking - want to use variable not literal

    Forms!form_SearchProducts!subform_ShowProducts.Fil ter = "CustomerName = " & sCustomerName

  3. #3
    Join Date
    Jan 2006
    Posts
    3
    I tried....

    Forms!form_SearchProducts!subform_ShowProducts.Fil ter = "CustomerName = " & sCustomerName
    Forms!form_SearchProducts!subform_ShowProducts.Fil terOn = True


    and received the same error as before.

    ??

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    dumb point is the space in fil ter in your code

    Forms!form_SearchProducts!subform_ShowProducts.Filter = "CustomerName = " & sCustomerName
    Forms!form_SearchProducts!subform_ShowProducts.FilterOn = True

    should read
    Forms!form_SearchProducts!subform_ShowProducts.Filter = "CustomerName = " & sCustomerName
    Forms!form_SearchProducts!subform_ShowProducts.FilterOn = True

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    Healdem,

    for us mere mortals, this site inserts a <space> after 50-chars-with-no-space unless you use the [code]tag (or so i imagined until now!).

    your post has no inserted <space> (this is either due to priviledges arising from your exalted status or, more likely, somehow linked to the [color] tag you used in your post)

    i have never once user a filter so i am poorly equipped to comment on the syntax. that hasn't stopped me in the past, so: maybe the filter needs a quoted string and quoted stringVars. if this is the case i would be tempted to try:
    _ShowProducts.Filter = "CustomerName = '" & sCustomerName & "'"

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    Jan 2006
    Posts
    3

    same error

    The space gets inserted by this webpage. I noticed it after my first post.

    Anyways, I tried...

    Forms!form_SearchProducts!subform_ShowProducts.Fil ter = "CustomerName = '" & sCustomerName & "'"

    same error...
    Run-time error '438'
    Object doesn't support this property or method.

Posting Permissions

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