Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass dataset-position to other form

Status
Not open for further replies.

Frihi

Programmer
Jun 24, 2001
48
CH
I have one form where the user selects his name from a Listbox and enters his password. On clicking a button I open the next Form and there are some textfields filled from the database, with his Name and highscore-points. I need to have the connection to the database to be able to update his points afterwards. Now how can I pass the selected Index of the first form to the second?

Up to now I have the following code (in frm1):

Dim frm2 As New frm2()

frm2.LoadDataSet()
frm2.BindingContext(objBenutzerDaten, "Benutzer").EndCurrentEdit()
frm2.BindingContext(objBenutzerDaten, "Benutzer").Position = Me.ListBox1.SelectedIndex

Something must be wrong with that, frm2 opens but goes to the first record. Anybody got an idea?
 
Well, it looks like nobody knows. But I think it must be possible. And it can't be so difficult. So please, isn't there anybody out there?
 
Thanks for the inumerous ideas. I have found a way now thanks to Jazz, in the vbCity.com forum.

First I create a module:

Module SharedFormInstances
Public myForm1 As New Form1()
Public myForm2 As New Form2()
End Module

That gives me access from each form to each other form, without having to declare a lot of things.

Now in the sub form_load I have to declare only "myForm(x)=Me". And then the code goes:

Private Sub Form2_load (...)
myForm1=Me
Me.LoadDataSet()
Me.BindingContext(objDataSet1, "MyTable").EndCurrentEdit()
Me.BindingContext(objDataSet1, "MyTable").Position = myForm2.ListBox1.SelectedIndex
End Sub

Hope that helps anybody else also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top