|
-
April 12th, 2001, 06:51 AM
#1
Changing Recordsource at run-time
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 ?
-
April 12th, 2001, 09:56 AM
#2
Re: Changing Recordsource at run-time
You need to refresh your data control
'adodc1.refresh' after changing the recordset
-
April 13th, 2001, 12:21 AM
#3
Re: Changing Recordsource at run-time
I tried doing Adodc1.Refresh also. What is happening is I am getting zero records in the data grid after changing the recordset.
Anything else that I am missing ?
-
April 13th, 2001, 05:56 AM
#4
Re: Changing Recordsource at run-time
This is how it has worked finally :
sql = "Select ......"
Adodc1.RecordSource = sql
Adodc1.Refresh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|