Using ListBox To select data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Codebug
    New Member
    • Feb 2008
    • 25

    Using ListBox To select data

    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?
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    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?

    Comment

    • mshmyob
      Recognized Expert Contributor
      • Jan 2008
      • 903

      #3
      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

      [CODE=vb]
      ' store the Index Array number for the List Box selection row
      vSelected = Me.lstPickFrom. ListIndex
      ' pass the 1st column (0 based) of the list box (lstPickFrom) to another open form
      Forms!frmReceiv e.txtReceive.Va lue = Me.lstPickFrom. Column(1, vSelected)
      [/CODE]
      Originally posted by Codebug
      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?

      Comment

      • Codebug
        New Member
        • Feb 2008
        • 25

        #4
        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

        Comment

        • blad3runn69
          New Member
          • Jul 2007
          • 59

          #5
          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...

          Comment

          Working...