Relations between forms.

johmolan

Well-known member
Joined
Oct 11, 2008
Messages
129
Programming Experience
Beginner
I have a project with 3 Forms.
The 1st Form sets the database connection to my SQL-database. then it opens the next Form.

In the second form I have 2 DataGridViews. 1 for my customertable and one for my ordertable. I have set the relations that if I select a customerID the orders for this customer appears in the DataGridView for the ordertable.

My problem appears when i need to open my 3rd form. Here I want to select a
OrderID in my dataGridView and press my openDetails button and open the 3rd form whch contains a DataGridView for the orderDetailstable. I have set the relation correct but I can not find the right code to transfer the commando for what data to display onto the 3rd form.

I hope you all understand what I am trying to figure out here, and all replies are welcome.



Best Regards
John
 
You can add a text field on form 2 and bind it with primary key of order table. Once bound correctly, this text field will show the id of field seleccted in your data grid.

Along with this you need to write a private function in form 3 to update the selected id and call this function on the click of data grid. Now in load event of third form you can write code to fetch the record of current id as set by the set id function.
 
Back
Top