Consulting

Results 1 to 6 of 6

Thread: Parameter query on Tabbed Form Syntax

  1. #1
    VBAX Regular
    Joined
    Jan 2019
    Posts
    19
    Location

    Parameter query on Tabbed Form Syntax

    Hello!

    I have a form with a cascading combo box - that works fine when it is opened by itself. However, when I make it a subform on an Tabbed Access Form - it cannot find the field for the criteria. I am pretty sure it is a Syntax thing - but I can't figure out what it should be.

    The form is frmInterest. When I put it in the Tab I linked the Member ID of the frmIntersrt to the ID of the parent form Contact Details. The form has 2 other fields - InterestMAin and interestsub - which are the dependent combo boxes. (pick a Main Interest Category and then the interest associated with that should appear.) I have thee requry code on the after update event of the main Interest Combo box and that is where it errors asking me for the value of that Combo box.

    When debuging on the after update event of the cbointerestmain combo box this is what I got for the form names:

    print Me.Parent.ActiveControl.Name
    FrmInterestSub

    print me.Name
    FrmInterest

    print Me.ActiveControl.Name
    cboInterestMain

    print me.Parent.name
    Contact Details

    So the Where cause in my query for the cboInterestsubName Combo box (the dependent combo box) is:

    [Forms]![contact details]![frminterestsub].[Form]![frminterest].[form]![cbointerestmain]


    I have tried various combonations of this to try to get it to see the combo box but it keeps asking for the value.

    if in the Immediate window I type print cbonterestmain.value - it returns the value - so it does have it - I just can't seem to reference it properly in the query.

    I know it should not matter that it is on a Tab -so I am wondering if it is because I want the subform to populate another value within the subform....

    Any help with this would be appreciated before i pull out all my hair.

  2. #2
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    This is the classic Syntax problem with Tabbed Subforms.
    I always struggle with getting the correct format and sequence of the [Form] anf field names.
    There is a simple way out of it if you can't find the correct sequence and that is to place a text field on the mainform and use the combo's after update event to place the combo choice in that Field.
    Therefore you only have one form and field to refer to in the querys criteria.
    if you could post the database with some dummy data in it I would try and get the sequence correct.

  3. #3
    VBAX Regular
    Joined
    Jan 2019
    Posts
    19
    Location
    TestDatabase1.zip

    OK - I have attached the database - it opened on to 2 forms. Main form and Contact list.

    If you double click a name on the contact list - it opens the tabbed form. The issue is with the Interest tab and the combo box for the "sub" interest.

    The query it is relating two is just called Query1

    I can try the text box on the main form - assuming I can get the syntax right to put it there and pull from that :P

  4. #4
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    Sorry I can't open the contacts table as it has later Features than Access 2007.
    But you should be able to refer to the subform directly when it is on the Tab.
    The tab should not be referred to at all.
    Have you tried
    [Forms]![contact details]![frminterest].[form]![cbointerestmain]
    or
    [Forms]![contact details].[Form]![frminterest]![cbointerestmain]

  5. #5
    VBAX Guru
    Joined
    Mar 2005
    Posts
    3,296
    Location
    OK, I did some work on it today and you have to be very careful about the names of the items, even though I have a subform on the Tab called "Workhardware Subform", it is actually called Child41 on the tab (single click the subform frame).
    So this works for me.
    [forms]![Worklog Tabbed]![Child41].[form]![HardwareID]

  6. #6
    VBAX Regular
    Joined
    Jan 2019
    Posts
    19
    Location
    Yes! That did it! Thanks! I was having a hard time with that syntax..

Posting Permissions

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