Question Opening Form for same record

chrisguk

Active member
Joined
Nov 20, 2011
Messages
29
Programming Experience
Beginner
I have a form which has my main data. On the form is a button to open another form called AccountNotes.


The table keys are as follows:


tblAccounts


pkAccountID
AccountDetail
etc etc


tblAccountNotes


pkAccountNotes
NotesDetail
fkAccountID


When I open the form AccountNotes how do I ensure it is tied or bound to the main form record I am viewing?
 
If you're not already, you should bind your data to a BindingSource and navigate the data using its members. The Current property exposes the current record, so you would pass that to the dialogue.
 
Follow the DW4 link in my sig and read the Creating a Simple Data APp link... at the end of that you will have (on the same form, but it's not a problem) a Parent/Child related datagrid pair

Now modify the example by adding another form, but this time drag only the child grid to the form, allow the dataset/bindingsource to be created, but delete the dataset afterwards, and (if you can get away with it would affecting the columns of the grid) delete the bindingsource.. Add a parameter to the constructor of this form to accept a bindingsource and then, on the parent form when you click the button to view the notes, create a new instance of the notes form passing the relevant bindingsource for the child data. this way the notes form just beomes an editor of the data.. it's the parent form's job to push it up and down to the db and manage the relations
 
Back
Top