By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

Using ListBox To select data

P: 25
I have a List Box on a form and the RowSource SQL is set in VB to display field data from a table.

How do I pass field data from the users selected row?
Feb 20 '08 #1
Share this Question
Share on Google+
4 Replies


jeffstl
Expert 100+
P: 432
Pass it how?

You mean have the selected row data be displayed to text boxes on your form?

Pass it to another form? Capture the row data into variables?
Feb 20 '08 #2

mshmyob
Expert 100+
P: 904
You haven't given much data.

This is the code to grab a single selected item for a ListBox and pass it to another open form.

You change the control names to match yours and the column number you want to pass.

Requirements - Both forms need to be opened.

Note: vSelected is an Integer

Expand|Select|Wrap|Line Numbers
  1. ' store the Index Array number for the List Box selection row
  2. vSelected = Me.lstPickFrom.ListIndex
  3. ' pass the 1st column (0 based) of the list box (lstPickFrom) to another open form
  4. Forms!frmReceive.txtReceive.Value = Me.lstPickFrom.Column(1, vSelected)
  5.  
I have a List Box on a form and the RowSource SQL is set in VB to display field data from a table.

How do I pass field data from the users selected row?
Feb 20 '08 #3

P: 25
Ok, figured this one out myself in the end, as always was simple

I just used the value property of the ListBox which is bound to the correct column of the list to return the value the user selected,

ie:


UserSelection = MyListBox.value
Feb 21 '08 #4

P: 59
in the new form goto textbox properties > data tab
default value = [Forms]![your_form]![your_control]
programatically maybe docmd.open method ,, stlinkcriteria method

depends on what ju do...
Feb 21 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.