Help Get Data From ListBox To TextBoxes

ColinKJ

Well-known Member
Joined
Jan 27, 2009
Messages
983
Hi All,

I'm very new to Access.

I'm starting to build a form, and I want to get two fields of data from the selection in the ListBox, one into Text1, and the other into Text2.

The List0 is from a query BU_Contract_List Which has the Contract No & Contract Name.

Contract No is the BoundColumn. the Control Source forText1 is set to =[List0], and that works fine.

When the form opens, only Text1 & Text2 are visible, when you double click in Text1, List0 is displayed. When you double click a selection in List0, the BoundColumn value, Contract No is displayed in Text1, and the List0 is hidden again.

I want to know how I get the Contract Name in Column2 of the List0 into Text2.

Can anyone help please.
 
Norie,

Thanks for that it works except, if I just use:

Code:
Private Sub List0_DblClick(Cancel As Integer)
Text4.Value = List0.Column(1)
Me.List0.Visible = False
End Sub

I get the error message "You can't hide a contol that has the focus"
If I add the Text4.SetFocus, it's ok

Code:
Private Sub List0_DblClick(Cancel As Integer)
Text4.Value = List0.Column(1)
Text4.SetFocus
Me.List0.Visible = False
End Sub

When I've created the sub-form, I'll make another post to get some help with how I pass the Contract No to a query to populate the sub-form.

Thanks for your perseverance.
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Colin

You shouldn't need to pass the contract no to a query.

You can link the subform and main form by that field so that the data in the subform will be based on the contract no selected in the main form.
 
Upvote 0
Thanks Norie, but that's easy for you to say, but at present I wouldn't know where to start with that.

I'm in the process of building a table with some example data, and trying to build the sub-form, so if ok with you. I'll get these to a point where I think I'm ready, then respond to this again.

Thanks again.
 
Upvote 0
Colin

Sorry if I offended in anyway.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top