Click to See Complete Forum and Search --> : ADO-Dataenvironment Question


tennisnet
October 15th, 2001, 01:41 PM
I use the following instructions to attach to an
Access database table using ADO and the Data environment:

DataEnvironment1.phone1
Set rs = DataEnvironment1.rsPhone1

How can I change "Phone1" in these instructions or build these instructions at runtime to reflect a different table name(the table name is being selected from a long list of table names at runtime)

Thanks---Tennisnet

jn8230
October 16th, 2001, 04:34 PM
Instead of using a DataEnvironment command to open your recordset, try to open the recordset dynamically using the DataEnvironment connection (DataEnvironment1.cnn) like this:

set rs = DataEnvironment1.cnn.Execute("SELECT * FROM " & strYourVariable



where strYourVariable is a table name in your database.
Alternately, you can define a command for each table, and then use a select case to determine which command to use at run time.

Hope this helps

Jason