Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31

    Exclamation how to reference a combo-box inside a tab, from main form on load event

    Hello,



    I am trying to load the values of a combo-box control that resides within a multi-tab control that is placed on a main form.

    I am trying to load the values on the Load event of the main form by using this statement:

    Code:
    Call InitializeCombo(Forms("DataCheck").Controls("Arranger").Controls("Title"), qstrcProfessions, 1, ",")
    The parameters are as follows: combo-box control, query to be executed to retrieve the values, number of columns, and special character that might be found in a string.

    When I try that code, I get the following error: The expression you entered refers to an object that is closed or doesn't exist

    This seems to happen only when I try to access a control inside a tab that is not the first tab, which is opened by default when the main form loads.

    Is there any way to work this issue around? If that line should not go placed in the Load event of the Main form, then inside what event of its own should it be placed?

    Many thanks for your help.




  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The tab is not part of the syntax. If it's on a subform:

    Forms Refer to Form and Subform properties and controls
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    the multi-tab control is on the main form.
    the combo-box control i am trying to access, is located on a subform on the 3rd tab.

    i also read that the subform and the combobox on it, should not be populated from the load event of the main form, since the subform should be self-aware.

    the issue that i have ran into is that when i place the call to the initializecombo subroutine, the load event of the subform does not execute. i am not sure how that works. if the only load event that executes is the one of the main form, then what even in the subform should i use to make the call the the subroutine that populates the combobox on the subform?
    Last edited by anavagomez; 05-15-2017 at 06:05 PM. Reason: added more details to my question.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Disregard the tab control. It is organizational and is not part of the syntax to refer to a control. You'd use the subform syntax from the link I posted.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    I thought that I was doing with the line below. Where Forms("DataCheck") is the main form, and ("Arranger") is the subform, and ("Title") is the combobox on the subform. I thought that is the right way to do it, but that is what returns the error I posted on the original question. Thank you.

    Forms("DataCheck").Controls("Arranger").Controls(" Title")

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    So you didn't look at the link, or try it? See if this works:

    Forms!DataCheck!Arranger.Form!Title
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    Hi pbaldy, I tried the link example is just that change in the syntax did not work. I got the same message returned.

    Thank you.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you attach the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    Hi pbaldy, the ms access database uses sql server in the background, if I attach it, it would not open for you.

    I can show you screenshots of the multi-tabs and of the combobox I am trying to access.

    This first screenshot shows most of the tabs, you can see that the first tab "copyright" has a combobox, for this combobox, the syntax you provided me with, works because is the first tab and I assume it does not throw an error because it the controls are available when the main form opens.

    Click image for larger version. 

Name:	ss1.PNG 
Views:	7 
Size:	10.1 KB 
ID:	28699

    below is the tab "arrangement", in this tab there is a subform, and in the subform there is a combobox NameNo, this is the combobox that returns the error: The expression you entered refers to an object that is closed or doesn't exist

    Click image for larger version. 

Name:	ss2.PNG 
Views:	7 
Size:	8.1 KB 
ID:	28701

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It would let me see the structure and perhaps see why that syntax is wrong.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    I tried to upload it but it surpases the limit of file size of the forum.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You were using "Title" before. Should that be "NameNo"? It needs to be the name of the combo, not the label.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31
    yes, I was using different names, I was using examples that I made up. Now that you can see the actual names, the combobox is NameNo. NameNo is the name of the combo, not the label.

    Click image for larger version. 

Name:	ss3.PNG 
Views:	7 
Size:	2.1 KB 
ID:	28703
    Last edited by anavagomez; 05-17-2017 at 10:46 AM. Reason: added ss3

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you export just this form and its related subforms to a new db and attach that here? It's a lot easier if I can see it.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    anavagomez is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Apr 2017
    Posts
    31

    Post files

    attaching the MTDDataCheck main form, and the subform ProfessionNotationArranger this is the subform that is located under the tab Arrangement and that contains the combobox NameNo
    Attached Files Attached Files

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. form on load event
    By vicsaccess in forum Programming
    Replies: 2
    Last Post: 01-13-2016, 11:33 PM
  2. Replies: 13
    Last Post: 09-10-2015, 03:37 PM
  3. Replies: 1
    Last Post: 03-29-2014, 07:46 PM
  4. Form Load Event
    By shah1419 in forum Forms
    Replies: 5
    Last Post: 01-13-2013, 12:42 PM
  5. Replies: 2
    Last Post: 06-09-2012, 01:56 AM

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