How do I populate a field on a form using a selection listbox?

G

Guest

I populate a listbox in a form with fields from a table. I want the user to
select a record from the list and have the primary key from the table to be
put in a field (same format, etc.) on the form which will then populate a new
record in another table with a foreign key back to the table from the
listbox.
 
G

Graham R Seach

Assuming the PK is the listbox's first column, the following will do it:

Private Sub MyList_Click()
If Not IsNull(Me.MyList) Then
Me.txtMyTextbox = Me.MyList.Column(0)
End If
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top