Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I need to populate a list box from a field in another table.
Users will add entries into table_1 and in order to update table_2, they need to be able to select the correct item in the data entry form for for table_2, via a listbox.

Anyone any ideas on the best way to do this?
Thanks
Posted
Updated 20-May-11 2:03am
v3
Comments
Karwa_Vivek 20-May-11 7:41am    
need Some more Explanation
Member 7940373 20-May-11 7:53am    
The users will enter details about documents into table_1. This data will include a document title field. At a later date, users will require to enter data relating to a particular document title, eg version number, associated docs, etc, into table_2.
Thanks
Karwa_Vivek 20-May-11 8:03am    
For this There must Be
a Common data Field or Primary
key in table_1
which must be the foreign key For table_2
Am I Correct ?
Member 7940373 20-May-11 8:16am    
Yes, thats correct

1 solution

I assume here that you must load the Listbox with the titles and On the Basis of your Document Title you
will able to update
load the Titles in listbox as
Public Sub Listboxdisp()
      Dim sd As New SqlDataAdapter("Select * from tableName", Mycon.con())
      Dim dt As New DataTable
      sd.Fill(dt)
      For i As Integer = 0 To dt.Rows.Count - 1
          ListBox1.Items.Add(dt.Rows(i).Item("Title"))
      Next


  End Sub

may you can call this on form load or on any button click
On the Data Entry Side place a textbox so that whenever the user selects the title from listbox.. It gets filled do it as, on the listbox Selected index Changed Event
TextBox1.Text = ListBox1.Text

And then user can input the Require info, than can update
may this can help you.I have assumed the Title As the Primary key.
Implement this as per your Need
 
Share this answer
 
Comments
Member 7940373 20-May-11 9:01am    
That's great. Many thanks for your help
sariqkhan 15-Dec-12 10:44am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900