[AccessD] Set recordsource of a form dynamically?!

Sad Der accessd666 at yahoo.com
Tue May 1 03:54:16 CDT 2007


Hi group,

I'm using an A2k2 ADP with an SQL Server 2000
database.
In the File=>Connection properties there is a
connection to the development server.

Using an ini file I dynamically connect to the
production server via a class cDataSvr.

In a module I've declared the following:
Public gDataSvr = cDataSvr

In the load event of a form I instantiate a recordset
using gDataSvr.

When I try the the line:
?gDataSvr.GetConnection I get the connection settings
of the production server.

I've tried the following code:

   Dim rstSource As ADODB.Recordset
   Set rstSource = New ADODB.Recordset
   
   With rstSource
      .ActiveConnection = gDataSvr.GetConnection()
      .Source = "select * from treport"
      .Open
   End With
   
   Me.RecordSource = rstSource.Source
   
   Set rstSource = Nothing

To my surprise I received DEVELOPMENT data instead of
PRODUCTION data!?!

My question:
How do tell the form to use the connection of gDataSvr
and NOT the connection instantiated in
File=>Connection?!?!

Regards,

Sander


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the AccessD mailing list