Changing ADO Data Control Recordsource 
Author Message
 Changing ADO Data Control Recordsource

I want to open a form that has an ADO data control with a particular record
based upon a value chosen in a combo box on another form.  Right now I am
using the recordset.filter command

  Dim Sql As String
  Dim f As frmCustomers
  Set f = New frmCustomers
  f.show
 f!datCustomers.Recordset.Filter = "CustomerId = '" & cboCustomer.BoundText
& "'"

I really would like to change the recordsource of the ado control before I
open up the form.  I tried the following code

  Dim f As frmCustomers
  Set f = New frmCustomers
   f!datCustomers.RecordSource = "Select * from Customers Where CustomerId =
'" & cboCustomer.BoundText & "'"
  f.Show

The form opened with the original Recordsource results (Select * from
Customers).  The only other thing I could think of was to use the .refresh
method, but I couldn't get this to work.

Thanks,

Russ Ganz



Mon, 24 May 2004 13:53:10 GMT  
 Changing ADO Data Control Recordsource
I guess you are using a RDS.DataControl.
If your DataControl object is named dc then
for requering the recordset :

dim rs as recordset
set rs= dc.recordset
if rs.state=adStateOpen then
    rs.close
endif
set rs.ActiveConnection=oCon ' your active connection
rs.CursorLocation=adUseClient
rs.CursorType=adOpenStatic
rs.LockType=adBatchOptimistic
rs.Source="Select ...."
rs.open
set dc.SourceRecordset = rs
' if your dc is associated to a grid control then
set oGrid.DataSource=dc

dim rs

Quote:
> I want to open a form that has an ADO data control with a particular
record
> based upon a value chosen in a combo box on another form.  Right now I am
> using the recordset.filter command

>   Dim Sql As String
>   Dim f As frmCustomers
>   Set f = New frmCustomers
>   f.show
>  f!datCustomers.Recordset.Filter = "CustomerId = '" &

cboCustomer.BoundText
Quote:
> & "'"

> I really would like to change the recordsource of the ado control before I
> open up the form.  I tried the following code

>   Dim f As frmCustomers
>   Set f = New frmCustomers
>    f!datCustomers.RecordSource = "Select * from Customers Where CustomerId
=
> '" & cboCustomer.BoundText & "'"
>   f.Show

> The form opened with the original Recordsource results (Select * from
> Customers).  The only other thing I could think of was to use the .refresh
> method, but I couldn't get this to work.

> Thanks,

> Russ Ganz



Tue, 25 May 2004 00:07:12 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need help changing Data Control Recordsource during runtime

2. Changing the recordsource to a data component for a bound control at runtime

3. Ado Data control - recordsource

4. Passing Params To SQL Server Stored Procs On ADO Data Control RecordSource Property Page

5. Changing ADO recordSource at runtime has no effect

6. Changing ADO recordSource at runtime has no effect

7. Changing RecordSource at Runtime with ADO/DAO

8. VB5 Data Control - Recordsource criteria from other control

9. Change recordsource data object at runtime

10. RecordSource change not reflected in data form

11. when is data changed in a ADO control?

12. Entering Params for SQL stored procedures on the ADO Control RecordSource Property Page

 

 
Powered by phpBB® Forum Software