[AccessD] Set recordsource of a form dynamically?!

Gustav Brock Gustav at cactus.dk
Tue May 1 04:36:26 CDT 2007


Hi Sander

Your gDataSvr.GetConnection() might return just a connection string and not a Connection object ...?

/gustav

>>> accessd666 at yahoo.com 01-05-2007 10:54 >>>
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






More information about the AccessD mailing list