I have a form admission and a another form attendance.
When i click on save button of the admission form the id which is contained in that form should be added to the combo box on the attendance form.

eg. say if i am saving the details of ID 4..When i click save button on the admission form and when i open the attendance form i should c that id listed / added in the combo box of attendance form. similary the list should go on populating...as n when i add id's.....

how to do it..
my admission id text box name is txtid.text
and my combobox on attendance form name is cmbattendance.

how to do it ? plz help me out ....i am novice at vb.net so simpler the soln better..it would be.//

cya
ROHAN
AWATING A QUICK RESPONSE...

I TRIED DECLARING THE TXTID.TEXT AND CMBATTENDANCE AS GLOBAL N TRIED
CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT)
HOWEVER ITS NOT WORKING...IE..THE COMBO BOX IS NOT FILLED WITH THE ID'S....?
PPLZ HELP ME OUT.....


I TRIED DECLARING THE TXTID.TEXT AND CMBATTENDANCE AS GLOBAL N TRIED
CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT)

I don't know if this is a mistake in your code or if you just copied your code incorrectly to the forum... in the statement CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT), since the combobox is on a different form than TXTID textbox, you need to specify which form the combobox is on (assuming the code is on the form with the textbox).

In other words, if the attendance form is called ATTENDANCE, then the code you specified in your post should be ATTENDANCE.CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT) Again, that is assuming the code is on the form with the TXTID textbox.

Please let us know if this helps!

I don't know if this is a mistake in your code or if you just copied your code incorrectly to the forum... in the statement CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT), since the combobox is on a different form than TXTID textbox, you need to specify which form the combobox is on (assuming the code is on the form with the textbox).

In other words, if the attendance form is called ATTENDANCE, then the code you specified in your post should be ATTENDANCE.CMBATTENDANCE.ITEMS.ADD(TXTID.TEXT) Again, that is assuming the code is on the form with the TXTID textbox.

Please let us know if this helps!

sure i will check out if this works...n ll surely let u knw!

thanks
cya
Rohan

Ur Problem is pretty simple. This is what you have to do:

When the ID is entered inot the textbox im assuming that it is saved in ur database in some column.

Your items in the Combobox have to be databound with the column that contains the ID's in the database.

1st: Add a new data source to your project : Data -> add data source
Select the table that contains the ID values and select the column that contains the ID values.
2nd: Once the datasource is created click on your combobox in design mode
(You will see a small white icon in the corner of the Combobox)
click on it and select bind to datasource
3Rd: Select the column that the ID is in and bind it to the combobox

This way all the Ids in the DB table will be displayed in the Combobox and any new added Id's will also be displayed. Cheers. Hope this helped.

Im here if you have anyother questions.

Does data have to be databound?

I ask because this won't work and I have no idea why:
Dim str As New StreamReader("C:\Duping\servers.txt")
Dim server As String = str.ReadToEnd().ToString()
str.Close()
Dim thisconnection As New SqlConnection("server=" & server & ";integrated security=True;database=projects")
Dim thisAdapter As New SqlDataAdapter()
Dim cmdthisAdapter As New SqlCommand("SELECT ProjectNumber, ProjectName FROM Projects", thisconnection)
thisAdapter.SelectCommand = cmdthisAdapter
Dim thisdataset As New DataSet()
thisAdapter.Fill(thisdataset, "ProjectNumbers")
For Each therow As DataRow In thisdataset.Tables("ProjectNumbers").Rows
Dim fart As String = therow("ProjectNumber").ToString()
ListBoxPROJECT.Items.Add(fart.ToString())
Next
thisconnection.Close()
I tried adding the string just to see if the data item was there and indeed each "therow" had a valid projectnumber but it just won't go into the listbox (I tried combobox too and that didn't work either)

Any ideas?

This article has been dead for over six months. Start a new discussion instead.