Populate form with list box values.

shabbaranks

Registered User.
Local time
Today, 20:48
Joined
Oct 17, 2011
Messages
300
Afternoon,

Im not sure this is the correct way to go about it but - here goes... So I have a lookup button which queries multiple tables to get Address details, and populates the address details (as a company could have more than 1 address) in a list box. I then select one of the address's from the list box

And thats as far as Ive got.

What I would like to do now is based on the item selected in the list, populate the main form with the values in the listbox (the main form is made up of multiple text boxes not another listbox), but Im not entirely sure how I achieve this. If anyone could guide me through the process of this that would be great. I havent added any current code as I didnt think how i populated the listbox was relevant - unless it is?

Thank you :)
 
Use the Double Click event of the Listbox.. It might look a bit messy..
Code:
Private Sub List2_DblClick(Cancel As Integer)
    Forms("yourMainFrom")!coAppAdd1TxtBox = Me.List2.Column(0, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppAdd2TxtBox = Me.List2.Column(1, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppAdd3TxtBox = Me.List2.Column(2, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppCountyTxtBox = Me.List2.Column(3, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppPostCodeTxtBox = Me.List2.Column(4, List2.ItemsSelected)
End Sub
Just change the Control Names..
 
Use the Double Click event of the Listbox.. It might look a bit messy..
Code:
Private Sub List2_DblClick(Cancel As Integer)
    Forms("yourMainFrom")!coAppAdd1TxtBox = Me.List2.Column(0, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppAdd2TxtBox = Me.List2.Column(1, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppAdd3TxtBox = Me.List2.Column(2, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppCountyTxtBox = Me.List2.Column(3, List2.ItemsSelected)
    Forms("yourMainFrom")!coAppPostCodeTxtBox = Me.List2.Column(4, List2.ItemsSelected)
End Sub
Just change the Control Names..


Exactly what I was after :)
 

Users who are viewing this thread

Back
Top Bottom