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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I open a child based on info from the parent

Status
Not open for further replies.

kisslogicgoodbye

Programmer
Mar 19, 2001
18
US
I have a parent form with a combo box with Company Name and ID. When a button is clicked, I want a child form to open that contains a datagrid populated from SQL2000. I want to pull only those records for the company that is choesen in the parent combobox. I'm missing some fundamental concept to get this working.

Heres code from the parent creating the child
private void openChecks(Object sender, EventArgs e){
// make the Checks panel the active panel
ChecksList newChecksList = new ChecksList();
newChecksList.MdiParent = this;
newChecksList.Show();
}

And here is code for the SELECT for the child:

this.sqlSelectCommand1.CommandText = "SELECT Checks_ID, PaidBy_ID, EnterBy, EnterDate, ChangeDate, ChangeBy, CheckNumber, CheckDate, DepositDate, Amount, Notes FROM tblChecks WHERE PaidBy_ID=@ParameterCompany";

this.sqlSelectCommand1.Connection = this.sqlConnection2;

this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("ParameterCompany", System.Data.SqlDbType.NVarChar));
 
In your child form, you need to provide a public function that accepts your parameters and stores them in member variables.

Remember, a form is a class in .NET, and all the data visibility rules apply.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top