Nihita Goel
April 12th, 2001, 06:51 AM
This is about DataGrid and ADO Control.
I have set RecordSource and datasource property at design time.
However I want to change the RecordSource at run time also.
Say My Screen is showing sales plan of a particular product. I have a ComboBox on screen and I want that as soon as user selects a product the datagrid should be populated by sales plan of that product. This is how I have implemented it.
Private Sub cbProduct_Validate(Cancel As Boolean)
Dim prod_table As String
prod_table = cbProduct.Text & "_SP"
sqlstr = "select * from " & prod_table & " order by warehouse_id "
rs.Close
rs.Open (sqlstr)
Set Adodc1.Recordset = rs
DataGrid1.Refresh
End Sub
But this is not working. Can you tell me what the problem is ?
I have set RecordSource and datasource property at design time.
However I want to change the RecordSource at run time also.
Say My Screen is showing sales plan of a particular product. I have a ComboBox on screen and I want that as soon as user selects a product the datagrid should be populated by sales plan of that product. This is how I have implemented it.
Private Sub cbProduct_Validate(Cancel As Boolean)
Dim prod_table As String
prod_table = cbProduct.Text & "_SP"
sqlstr = "select * from " & prod_table & " order by warehouse_id "
rs.Close
rs.Open (sqlstr)
Set Adodc1.Recordset = rs
DataGrid1.Refresh
End Sub
But this is not working. Can you tell me what the problem is ?