Transfer Listbox data to Textbox

LB79

Registered User.
Local time
Today, 23:52
Joined
Oct 26, 2007
Messages
505
Hello,

I wonder if someone can help me.
I have a form with a listbox link to a table. It has 3 columns (A/B/C).
I want to have a function whereby when i click a record in the listbox, the contents of column B transfers to a textbox.
Whats the best way to do this?

Thank for any help.
 
On the AfterUpdate() event of the listbox ...

Code:
Me.txtControlName = Me.lstListBoxName.Column(x).

Where x is the column number of the underlying data source (in case you have hidden columns in the list box) starting with 0, 1, 2 ...

-dK
 
Thanks!! Thats great!
 
Hi Dkinley,

I have similar problem, but mine is 3 x 3 records, 3 cols and 3 rows. Like what you said me.txtcontrolName = me.lstListBoxname.column(x) which it works fine, how about if i want to transfer the row 2 and row 3 records, what should i do?

Please need your help.
Thank you.

JE



On the AfterUpdate() event of the listbox ...

Code:
Me.txtControlName = Me.lstListBoxName.Column(x).

Where x is the column number of the underlying data source (in case you have hidden columns in the list box) starting with 0, 1, 2 ...

-dK
 
Hehe .. now you are asking a different question. I don't think it can be done without perhaps using some DAO. I would look for a different means of approach because the maintenance could be a headached if changes are required. If what you want to do is populate an form, you can do this through the form's record source. A sample is here.

If you want to display more than one record in form, then you will need to use a subform. The links can be established through foreign keys.

Take the example in the link. This could populate the subform (either in datasheet or continuous forms) to give you what you wanted based on these foreign keys.

Another method would be to set up the form to be bound to a query that derives the result you want. Alternate methods would be to use DLookups (based on the foreign keys) but I don't think you would like the results.

Hope that helps ...
-dK
 

Users who are viewing this thread

Back
Top Bottom