+ Reply to Thread
Results 1 to 10 of 10

listbox to combobox

  1. #1
    Registered User
    Join Date
    08-11-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    11

    listbox to combobox

    Hi guys,

    I've found this bit of code that I'd quite like to use but rather than having the values show up in a listbox, I'd like them to be selected from a combobox.

    Can someone provide assistance please?

    Thanks,

    Dom

    Please Login or Register  to view this content.
    Last edited by dcompagnone; 08-12-2010 at 04:16 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: listbox to combobox

    Change the listbox references to point at your combobox and use the Exit event (or Change if you prefer) rather than the click event.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    08-11-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: listbox to combobox

    I have no idea why it didn't work when I tried that the first time but it's working now, so thank you.

    It's thrown up a new challenge though:

    When I click 'Amend' on my form, I'm getting a type-mismatch on the ' .Cells(n, 1).Value = one' line.

    Any clues?



    Please Login or Register  to view this content.

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: listbox to combobox

    What is the value of 'one' at the time?

  5. #5
    Registered User
    Join Date
    08-11-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: listbox to combobox

    Probably easier if I just attach the file as it's only a tiny tester at the moment.

    I can't work out what's going wrong here.
    The problem is on the 'Amend' Button

    The ComboBox drops down and works fine but I can't get past this type mismatch problem. Been looking at it for so long now, I'm blind to it!!

    Take a look!

    Dom
    Attached Files Attached Files

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: listbox to combobox

    Your problem is that in this line:
    Please Login or Register  to view this content.
    there is no match (you are searching for a text representation of a number in a column of actual numbers) so n is actually an error value, which you can't then use as a row number. You need to use:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    08-11-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: listbox to combobox

    that was actually my error. colum c, even in the new database will be a text value.

    I'm still getting errors though. nothing updates now - clicking 'edit' on the form just converts the date format!

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: listbox to combobox

    Works fine for me after making the adjustment I mentioned.

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: listbox to combobox

    or see the attachment:
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    08-11-2010
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: listbox to combobox

    romper, you have been a stomper.

    Thank you for your help. I had deleted an extra line when I made the change as you suggested.

    Solved.

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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