+ Reply to Thread
Results 1 to 15 of 15

Combobox value defines Combobox Rowsource

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Combobox value defines Combobox Rowsource

    Hi all, I need some help getting this code to work. I would like the value of Combobox1 to define the Combobox2 Rowsource.

    The basic concept works, except for adding the line of code:

    Please Login or Register  to view this content.
    to my UserForm_Initialize that already has existing functions in it.....

    Please Login or Register  to view this content.
    Appreciate your help!
    Attached Files Attached Files

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    The code works fine apart from this part which causes an error because there is no sheet called 'DateSheet - Fitness'.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Combobox value defines Combobox Rowsource

    try using a range name and set it as follows
    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    Sorry, added the DataSheet.

    Get the following error:

    Run-time error 91
    Object variable or With block variable not set
    Attached Files Attached Files

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    Same code causing the problem but different error for a different reason.

    The reason this time is that 'DataSheet - Fitness' is completely blank so LR can't be found.

  6. #6
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    apologies, should have posted my working project....

    Please have a look at UserForm1

    thanks!
    Attached Files Attached Files

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    Which userform is causing the error and what's the error message?
    Last edited by Norie; 09-03-2013 at 07:47 AM.

  8. #8
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    UserForm1

    Run-time error 424
    Object Required

    It only happens when adding this line:

    Please Login or Register  to view this content.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    When I try and show UserForm1 I get an 'object required' error here.
    Please Login or Register  to view this content.
    I can't find anything called LookupLists.

    By the way, if you add this (which you should have in all modules anyway) at the top of the module,
    Please Login or Register  to view this content.
    there are LookupLists is highlighted again as are various other undeclared variables.

  10. #10
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    Hi Norie, not sure I am following.

    You get the 'object required' the first time round, but when you then go and debug, you get the issue here:

    Run-time error 424
    Object Required

    The LookupLists is the name of my sheet.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    I get the error on the same line as you do but when I add Option Explicit, then goto Debug>Compile... I get the same error 3 times here.
    Please Login or Register  to view this content.
    The reason is you don't have sheet with the code name LookupLists, that's one of the sheets tab name.

    Try replacing LookupLists with Worksheets("LookupLists").

    I also get errors wherever dteDateSelected, ctrl or FirstRowAdd appear.

    PS If want to prevent these types of errors try adding Option Expicit to every module.

    You can actually make that happen automatically if you goto Tools>Options... and check Require variable declaration on the Editor tab.

  12. #12
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    wow! I see what you mean. I added the option explicit to my modules, and got all sorts of errors!

    I must be honest, my project seems to work fine, except for when I added the function to do the following: the value of Combobox1 to define the Combobox2 Rowsource.

    I also tried changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    but then get error: Run-time error 70; Access Denied.

    Do you have any thoughts on how I can add my needed functionality to my project, without having to redo most of it?

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    That's becuase you've set the RowSource property of the combobox cbxTypeEncounter.

    You can't use RowSource and then try to populate using List it's one or the other preferably the latter.

  14. #14
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Combobox value defines Combobox Rowsource

    UUUURRGGGGGHHHH!!!!!!!!!!!!!!!!

    How frustrating was that??

    Thanks for your great help and patience, Norie!

    By the way, what does the Option Explicit do?

  15. #15
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox value defines Combobox Rowsource

    It forces you to declare variables.

    Which is a good thing as it can help you find typos, misspelling, undeclared variables...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Add RowSource to Userform ComboBox based on value on Another ComboBox
    By Baziwan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2012, 01:17 PM
  2. Way to populate combobox rowsource based on previous combobox value
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-08-2012, 12:50 AM
  3. Combobox: How to determine the location of the selected item if combobox has rowsource
    By ahsanzafar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2012, 03:24 PM
  4. Combobox rowsource
    By mike0123m in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2009, 02:46 PM
  5. Combobox rowsource
    By Marinos Andreou in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2006, 01:10 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1