Results 1 to 9 of 9
  1. #1
    LFosterAccess is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    1

    Basing one combo box on another in a subform


    I have created a combo box that limits its list based on the selection made in another combo box. I also entered an event procedure (AfterUpdate) to keep the combo box updated. It works fine when it is in its own form; however, when I put these combo boxes in a subform, I am prompted for a parameter value when opening the main form. This is most likely because of the order of event procedures but I do not know how to fix it.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The syntax to reference a control on a form is different when it is a SubForm.
    http://www.mvps.org/access/forms/frm0031.htm

  3. #3
    bkelly is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    17

    Great link

    I was just browsing and found this thread.
    This goes in the favorites.
    Great link RuralGuy.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by bkelly View Post
    I was just browsing and found this thread.
    This goes in the favorites.
    Great link RuralGuy.
    That site is probably either the best or at least way at the top of the list of great Access sites.

  5. #5
    brock is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    3

    Exclamation What now

    Quote Originally Posted by LFosterAccess View Post
    I have created a combo box that limits its list based on the selection made in another combo box. I also entered an event procedure (AfterUpdate) to keep the combo box updated. It works fine when it is in its own form; however, when I put these combo boxes in a subform, I am prompted for a parameter value when opening the main form. This is most likely because of the order of event procedures but I do not know how to fix it.
    Hi i Have same problem but i cant figure the info in the link provided by RuralGuy. Can you help me with sintax for my case.



    I have form TESTINFO as a subform of TESTEVENT.
    I am using 2 combo boxes in TESTINFO (First combo is filtering second ).
    Its working on TESTINFO form but when is it a SUBFORM to TESTEVENT i get popup to populate the parametar. ( I used microsoft guide to get to this point)

    //Query name cboQuestion - criteria for TestID
    IIF(IsNull([Forms]![TESTINFO]![cboTestCode]), [TestID],[Forms]![TESTINFO]![cboTestCode])

    AlSO

    //ON CURRENT - I got this on FORM TESTINFO
    Private Sub Form_Current()
    Me!cboQuestion.Requery
    End Sub


    //AFTER UPDATE COMBO - I SET THIS UP ON first combo box
    Private Sub cboTestCode_AfterUpdate()
    Me!cboQuestion.Requery
    Me!cboQuestion.SetFocus

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    A form used as a SubForm is no longer in the Forms collection. In order to reference the SubForm you need to go through the MainForm.
    Where as a MainForm the reference is:
    Forms.MainForm.ControlName
    ...as a SubForm the reference would be:
    Forms.MainForm.SubFormControl.FORM.ControlName

  7. #7
    brock is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    3

    Newb

    Quote Originally Posted by RuralGuy View Post
    A form used as a SubForm is no longer in the Forms collection. In order to reference the SubForm you need to go through the MainForm.
    Where as a MainForm the reference is:
    Forms.MainForm.ControlName
    ...as a SubForm the reference would be:
    Forms.MainForm.SubFormControl.FORM.ControlName
    Sorry if this is annoying to you, but i dont understand

    1.Do i need to change the query or events code ...or both
    2. My sintax has all this ! [] and yours is just ". . . "

    If you can give me an example that would help me visualize ( i dont know what should i put for SubformControl.FORM)
    ???????????? .???
    Thanks

  8. #8
    brock is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2009
    Posts
    3
    HOLD ON Before you snap at me ...I think i GOT IT ( query)

    IIf(IsNull([Forms].[TESTEVENT].[TESTINFO].[FORM].[cboTestCode]),[TestID],[Forms].[TESTEVENT].[TESTINFO].[FORM].[cboTestCode])));

    Confusing part was SubformControl which = "SUBFORM" ///"TESTINFO" in my case

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Excellent! FYI, forms are displayed on other form by the use of a SubFormControl and this SubFormControl has a name of its own that defaults to the name of the form it is displaying but need not remain so. It is the name of the SubFormControl that is used in the syntax to reference controls on a SubForm.

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

Similar Threads

  1. Replies: 1
    Last Post: 08-26-2009, 10:45 AM
  2. Replies: 1
    Last Post: 08-03-2009, 08:24 AM
  3. Replies: 6
    Last Post: 06-03-2009, 02:01 PM
  4. Replies: 0
    Last Post: 08-17-2008, 12:19 PM
  5. Replies: 1
    Last Post: 12-10-2005, 04:52 PM

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