Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114

    Populate Text Box With Selected Value From List Box

    I have a single select list box where the user will select the manager assigned to the project. I want the selected value from this list box called lbxManager to populate the text box called txtManager. I tried to set the DefaultValue of txtManager as = lbxManager.Value and =lbxManager.ItemsSelected but neither one will populate this textbox with the selected value.

    What must I do to get the selected value from lbxManager into txtManager?

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    OnClick on lbxManager:
    me.txtManager = me.lbxManager

  3. #3
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    Quote Originally Posted by Bulzie View Post
    OnClick on lbxManager:
    me.txtManager = me.lbxManager
    This gives me an invalid use of null error. However, I have selected an item from me.lbxManager

  4. #4
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    If it changes how you would view this, I set the values by using the row source of the field. It is only 1 column, non multi-select and 5 values to choose from.

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    umm, works in my tests. put in breakpoint on that line and see what me.lbxManager is when you hover mouse over it once code is stopped.

  6. #6
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    Quote Originally Posted by Bulzie View Post
    umm, works in my tests. put in breakpoint on that line and see what me.lbxManager is when you hover mouse over it once code is stopped.
    If I add just Me.lbxManager in the VBA editor it gives errors
    Compile Error:
    Invalid use of property.

  7. #7
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    Is the list box bound or unbound? Maybe try me.lbxManager.Column(0), but if single column you shouldn't have to.

  8. #8
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    It is bound

    If I use
    Debug.Print Me.lbxManager it shows Null

    What is even more interesting is I did this
    Code:
        If Me.lbxManager.ItemsSelected.Count = 0 Then
            DoCmd.SetWarnings True
            Exit Sub
        Else
            Debug.Print Me.lbxManager
        End If
    And it shows that the count is > 0 as it goes to the else block, BUT it prints NULL

  9. #9
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    What are the datatypes and values in the list box and the destination field? Can you give example data.

  10. #10
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Are you absolutely positive that the Listbox has its MultiSelect Property set to None?

    Me.lbxManager

    is the same as

    Me.lbxManager.Value.

    And when the MultiSelect Property is set to set to anything other than None...the Listbox no longer has a Value...and you'll see the errors you're seeing.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    Quote Originally Posted by Bulzie View Post
    What are the datatypes and values in the list box and the destination field? Can you give example data.
    DataType is short text. Actual options to choose from are:
    Code:
    Robertson
    Jones
    Jackson
    Menendez
    Juevos
    Jackson

  12. #12
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    Quote Originally Posted by Missinglinq View Post
    Are you absolutely positive that the Listbox has its MultiSelect Property set to None?

    Me.lbxManager

    is the same as

    Me.lbxManager.Value.

    And when the MultiSelect Property is set to set to anything other than None...the Listbox no longer has a Value...and you'll see the errors you're seeing.

    Linq ;0)>
    Yes, just confirmed that the Multi Select property of this field is set to none

  13. #13
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,469
    Create another list box, manually enter the values, then try to move it to the text field. See if that works.

  14. #14
    chalupabatman is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    114
    Quote Originally Posted by Bulzie View Post
    Create another list box, manually enter the values, then try to move it to the text field. See if that works.
    What do you mean by manually enter the values?

  15. #15
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    With the MultiSelect Property set to None, it makes no sense for Me.lbxManager in the VBA editor to pop the error

    Compile Error:
    Invalid use of property.


    And when things simply make no sense, I always wonder about corruption!

    Although we usually think of Forms, and even entire Databases, when we speak of corruption, Controls, such as Listboxes, can and do become corrupted, and seem particularly susceptible to this during app development. The test/cure for this is short and simple...delete the Control and then re-create it.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 4
    Last Post: 07-27-2016, 12:07 PM
  2. Replies: 1
    Last Post: 01-23-2014, 05:21 PM
  3. Replies: 1
    Last Post: 11-23-2012, 10:26 PM
  4. Replies: 10
    Last Post: 10-10-2011, 08:08 PM
  5. Replies: 4
    Last Post: 06-16-2011, 09:30 PM

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