Results 1 to 13 of 13
  1. #1
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44

    Entering txt into a listbox

    I have a listbox that I cannot figure out why it is not displaying:

    Row Source Type = Value List
    Bound Column = 1
    Limit to list= No
    Allow Value List Edits = Yes



    When use the command
    Me.List1.AddItem Item:=Str
    (Str is a string value)

    I can List1.listcount and it is 1 but the value does not show in the box.
    I tried List1.Requery and still nothing.. Am I doing something wrong?

  2. #2
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    Quote Originally Posted by JB510 View Post
    I have a Combobox that I cannot figure out why it is not displaying:

    Row Source Type = Value List
    Bound Column = 1
    Limit to list= No
    Allow Value List Edits = Yes

    When use the command
    Me.Combobox1.AddItem Item:=Str
    (Str is a string value)

    I can Combobox1.listcount and it is 1 but the value does not show in the box.
    I tried Combobox1.Requery and still nothing.. Am I doing something wrong?
    I changed it to a Listbox and it worked?? - Why?

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    Why does your original post reference listbox yet quote references combobox. Edit original post.

    Adding item to combobox list does not cause it to be selected and display in the box - must set combobox Value property.

    Adding item to listbox list will display the item but again, it is not selected.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    The typical setup of a combobox involves also specifying how many columns it will have, which is probably 2 for you, and formatting the columns, something to "0;2", which means 0 width first column, 2 width for second column, etc. All of that is in the format tab of the combobox.

  5. #5
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    I did not want to confuse things so I said it was a listbox but no, as corrected, it was a combo box.

    I don't need it selected, I just wanted to drop serial number(s) in there imported from a text file. (I started with one Serial number in a text file.)
    My code put the number in the Row Source of the combo box (I don't know if it is to go in there) but it does not show up in the box on the screen.
    ?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,972
    What do you mean by 'does not show up in the box on the screen'? It won't until item is selected or combobox Value is set.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    Quote Originally Posted by June7 View Post
    What do you mean by 'does not show up in the box on the screen'? It won't until item is selected or combobox Value is set.
    Me.Combobox1.AddItem Item:=Str
    txtGood = combobox1.listcount
    txtTotal = combobox1.listcount
    txtBad.setfocus

    Where Str is the serial number.
    It did not put the serial number into the combo box.
    It did however make txtGood = 1 and txtTotal = 1




  8. #8
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    That means it's adding the item but it's not showing it. What is the rowsource of your combobox? Also, where is Str coming from?

  9. #9
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    Row Source was Value List.
    Str is a string value. I can step over it using F8 and it is populated correctly B5L604001234

    That is why I posted.. I could not figure out what I was doing wrong.
    I deleted the combo box and tried the same code with a list box. The list box worked.

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    I would recommend you use a table\query for the row source and not a value list. There is a character number limitation for the value lists and also it makes it harder to remove bad\duplicate entries.

    Some reading for you:
    https://www.datawright.com.au/access...ur%20rowsource.
    http://allenbrowne.com/ser-27.html

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    Noted.. It is only to list a max of 20 serial numbers anyway so I am not worried about running out of space.
    It still does not explain why it would not show them in the combo box.

  12. #12
    Edgar is offline Competent Performer
    Windows 8 Access 2016
    Join Date
    Dec 2022
    Posts
    274
    If you are adding a string with this:
    Me.Combobox1.AddItem Item:=Str

    And it works, but it does not show what you want, then something else is happening in your code, JB510. How does the rest of the code look?

  13. #13
    JB510's Avatar
    JB510 is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Ontario
    Posts
    44
    The rest of the code is a work in progress.. as mentioned, I got it to work by making it a listbox.
    Mark it up as unknown...

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

Similar Threads

  1. Replies: 3
    Last Post: 12-03-2020, 05:11 PM
  2. Replies: 2
    Last Post: 03-23-2014, 06:50 AM
  3. Replies: 3
    Last Post: 12-13-2012, 04:40 AM
  4. Replies: 1
    Last Post: 09-10-2012, 11:21 PM
  5. Replies: 1
    Last Post: 07-26-2012, 11:45 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