[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
Re: Set value of Textbox from a combo box column
Perhaps something like this
VB Code:
Private Sub ComboBox1_Click()
Debug.Print ComboBox1.Column(1, ComboBox1.ListIndex)
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.
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?
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.