02-25-2003, 07:00 PM
One Flexgrid depending on another
I have two flexgrids on one form. One is for customers(Customers Table) and the other is for orders(Orders Table) that these customers placed. When you click on the customer's flexgrid you should see the orders that were placed by that customer.
The customer's table and the orders table are linked through CUSTID.
CUSTID is the primary key in the customers table and a foreign key in the orders table.
Populating the customer flexgrid was easy. I just created a data environment (deReports.cmCustomers) that selected fields from the customer table for the customer flexgrid. I set the data source to deReports and data member to cmCustomers
My problem is populating the order flexgrid. I have the information for the order flexgrid but I can't get it to display anything each time I click the customer flexgrid. What I've done so far is:
created an sql statement in a data environment(deReports.cmCustOrder) that says:
"select * from orders where custid=?"
Private Sub flexCustomers_Click() ' the customer grid
I did the following:
Dim intCustID as Integer 'intCustID is parameter to be fed to sql
intCustID = flexCustomers.Text 'CustID click goes to parameter
If deReports.rscmCustOrder.State = adStateOpen then
End If 'close recordset before applying parameter to ? in sql
deReports.cmCustOrder intCustID 'send paramenter to ? in sql
Ok up to this point I know everything works. The data environment(deReports.cmCustOrder) for the orders flex grid gets fed the parameter into its ?. If I put a msg box:
in this code I'll see that the order data changes in the Msg box based on where I click on the Customer's flex grid.
But the orders flex grid doesn't show anything. I know the data is there though from the message box.
I've set the orders flex grid to .refresh after this click procedure.
I've set the data source to deReports and the data member to
Still no data in the orders flexgrid.
How can I get the orders grid to set itself to the new recordset information that was created from the intCustID parameter?