Results 1 to 6 of 6
  1. #1
    mayhem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    4

    adding items to form list box not showing item text

    Hello,


    I'm new to access, so please be patient.

    I have a form with a dropdown box. I have a listbox on the same form that starts disabled.

    On change of my drop down box, I want to populate my (multiselect) listbox with items, relative to my drop down box field.

    In design mode I have my drop down box created and my empty listbox (with multi select set in properties).

    My drop down box is populated by a query and works right.

    I have edited the vba for the on change event of the drop down box to enable my listbox, I then grab the list box item count and use a fit loop to RemoveItem all items.

    Then I run a query to get new values based on the value in my drop down box.

    I then use the list box additem method to add items to my list box based on the record set. As a debug, I use msgbox to print my record set value and it appears correctly.

    When running my form, and changing my drop down box, I can see that my listbox is adding items because I can use the multiselect functionality, the only problem is that I don't see the item labels. Wtf. I am using default settings, I tried setting font to black from some shade of blue, etc.

    Anyone know why the labels aren't showing?

    I'll post my code tomorrow, in not at work right now. Posting from my phone.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Your terminology is a bit confusing, but aside from that it sounds like you should start over as you're making this way too difficult. You say your "drop down box" (combo box) item list is a query (thus the combo box has a row source and not a value list) and it's working? Your listbox rowsource should be a query that uses the combo box value as criteria, and in the After_Update (not on change) of the combo, you requery the listbox. Maybe add a message box if the action produces no records. As for labels - don't know what you mean as a listbox doesn't have labels. Maybe you mean row headings? Or do you mean there is another column that you're not seeing that you're using to describe ("label") the row value.
    Last edited by Micron; 03-17-2016 at 09:25 PM. Reason: clarify combo row source vs list
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    mayhem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    4
    Yes I have a combo box for my first control. By label, I guess I meant row heading. I'm assuming when you use the additem method of listbox, the string you give it as an argument is the one that's suppose to appear in the listbox. That is the label I was referring to.
    I'll try changing to the after_update event, although I don't see why on change wouldn't work. For example, I get the value of my combo box and use a message box to display it on change and it gets the value fine.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    A row heading is not a list item, so you cannot add it. The 'Column Heads' property of a list box or combo box is what controls the appearance (or not) of headers. You can use alias names for fields in the underlying data source if the field names are not appropriate for labels. As for the event you chose, the on change event occurs whenever the value of the control changes. This means if the user can type in the control, it fires after each key press. That's why the After_Update event is the better choice for handling control value changes in your case, especially if doing the other means you're going to end up trying to populate a listbox based on partial values.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    mayhem is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    4
    Quote Originally Posted by Micron View Post
    A row heading is not a list item, so you cannot add it. The 'Column Heads' property of a list box or combo box is what controls the appearance (or not) of headers. You can use alias names for fields in the underlying data source if the field names are not appropriate for labels. As for the event you chose, the on change event occurs whenever the value of the control changes. This means if the user can type in the control, it fires after each key press. That's why the After_Update event is the better choice for handling control value changes in your case, especially if doing the other means you're going to end up trying to populate a listbox based on partial values.
    oh i see, I did not realise that about the onChange event, i've only used onChange in excel and it works differently.

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    I too have been frustrated by the differences in Excel and Access vba, such as when I discovered that an Excel form is not called a form (at least not in Excel vba).
    You would have thought they could have been on the same page with that one.

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

Similar Threads

  1. Replies: 21
    Last Post: 10-19-2015, 05:38 PM
  2. Replies: 15
    Last Post: 10-08-2015, 03:33 PM
  3. First item selected not showing up in text string
    By Gina Maylone in forum Access
    Replies: 4
    Last Post: 08-28-2015, 07:46 AM
  4. Replies: 2
    Last Post: 10-22-2014, 11:37 AM
  5. The text you entered isn't an item in the list
    By mariusvdw in forum Access
    Replies: 3
    Last Post: 05-09-2012, 11:31 AM

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