Share via

Populate text boxes based on list box selection

Anonymous
2010-06-17T21:00:35+00:00

I have a form with an unbound list box and unbound text boxes. The list box populates with no problem. I'd like the user to be able to click on a selection in the list box, and have each text box populate with a corresponding field. Can anyone explain to me how to do this or provide a link that explains it. I would greatly appreciate it!

Thanks for any input and ideas.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-06-17T21:32:24+00:00

If your listbox is set to only allow 1 item selection, Multi Select = None.  Then you can simply do:

    Me.TextBoxControlName = Me.ListboxControlName

But why would you need to display this information twice?

If your listbox allows multi-selection then you need a loop, such as :

    With Me.ListboxControlName

        For Each varItem In .ItemsSelected

            If Not IsNull(varItem) Then

                Me.TextBoxControlName = Me.TextBoxControlName & ", " & .ItemData(varItem)

            End If

        Next

    End With

I hope this helps,

Daniel Pineault

http://www.cardaconsultants.com

MS Access Tips and Code Samples: http://www.devhut.net

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2010-06-17T21:22:00+00:00

WHere do these "corresponding fields" exist?  If they are included in the list box's RowSource query, then you can display those fields by using text box expressions like:

   =thelistbox.Column(N)

where N is the 0 based number of the corresponding field.

If that is not what you want, please provide more details.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2010-06-18T18:41:08+00:00

    Thanks for both replies! They were both helpful and the issue has been solved. Thanks you so much.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments