Results 1 to 4 of 4

Thread: [RESOLVED] Set value of Textbox from a combo box column

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    [RESOLVED] Set value of Textbox from a combo box column

    I am trying to set the value of a textbox named "Address" by referencing the value of column 1 of a combo box named "Location". The following code is not working for me. Please help

    Private Sub Location_Change()
    Address.Value = Location.Column(1)


    End Sub

    I have also tried the following code..

    Private Sub Location_Change()
    Address.Value = [Form]![Location].[Column](1)

    End Sub

    [Resolution:
    Private Sub Location_Change()
    Address.Value = Location.Column(1, Location.ListIndex)
    End Sub
    Thank You "bushmobile"

    carbo
    Last edited by carbo; Apr 29th, 2006 at 03:00 PM.

  2. #2
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Set value of Textbox from a combo box column

    Perhaps something like this
    VB Code:
    1. Private Sub ComboBox1_Click()
    2.     Debug.Print ComboBox1.Column(1, ComboBox1.ListIndex)
    3. End Sub

    Since you're talking about columns in a ComboBox I'm assuming your either using VBA within an Office application, or you've referenced Microsoft Forms 2.0 Object Library. If it is the latter then you should know that library is non-redistributable and you would not be able to package it with your application. Your end-users would have to already have MSOffice installed on their machines. There is a way around it by getting them to download some other application that is free (can't remember the name) but generally the controls in that dll are avoided. See MSDN for more info.

  3. #3
    Lively Member
    Join Date
    Apr 2006
    Location
    Planet Earth
    Posts
    64

    Re: Set value of Textbox from a combo box column

    Sorry, but hat do u mean by " set the value of a textbox named "Address" by referencing the value of column 1 of a combo box named "Location" ".Can u explain more?
    I'm Still learning!
    satisfied/not satisfied, PLEASE TAKE SOME TIME TO rate me accordingly.
    Ur opinions helps me to be better!


    Appreciation Triggers Another Good Deeds.

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    50

    Re: Set value of Textbox from a combo box column

    The combo box contains not only the place name i.e. "Wal-Mart" but also in column 1 contains the address. So while the value for "Location" (combo box) will be "Wal-Mart" the next field is for the actual address of "Wal-Mart" which is stored in column 1, So when I select "Wal-Mart" from the combo box i would like for it to pass the address value of the next field "Address" to that field on an "on change" event.

Posting Permissions

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



Click Here to Expand Forum to Full Width