How to pass a variable to a SET statement

How to pass a variable to a SET statement

Post by reimancan.. » Wed, 10 Nov 1999 04:00:00



Consider this code.  It works fine so long as I explicitly define the
table in the "Set tdf =" statement.  What I want to do is the
equivalent of Set tdf = "dbs.TableDefs!" & strTableName.  This of
course produces an error otherwise I wouldn't be posting this.  How do
you use a variable in a Set Statement?

Sub DataDict(strTableName)
  Dim dbs as Database
  Dim tdf As TableDef
  Dim fld As Field
  SeT dbs = CurrentDB
  Set tdf = dbs.TableDefs!tblRental            THIS WORKS
  Set tdf = dbs.TableDefs! & strTbleName       THIS DOES NOT
  For Each fld In tdf.Fields
  Debug.Print fld.Name
End Sub

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

How to pass a variable to a SET statement

Post by Kirk Allen Evan » Wed, 10 Nov 1999 04:00:00




>   Set tdf = dbs.TableDefs!tblRental            THIS WORKS
>   Set tdf = dbs.TableDefs! & strTbleName       THIS DOES NOT

Use the name as a reference to the tabledefs collection in this case
instead of the bang (!) operator.

Set tdf = dbs.TableDefs(strTbleName)

--
Kirk Allen Evans

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Can you pass a where with multiple statements without a variable for each where statement

Gary:


      I have been trying to write a series of stored procedures which trigger and pass each stored procedure values to complete my select statements.
  My First Stored procedure is a query definition in multiple fields.

  CREATE PROCEDURE sp_Get_alloc_param AS




  FROM Allocation_rules  



  Now I tried to create sp_get_alloc_details that issues

  CREATE PROCEDURE sp_get_alloc_details

  AS

  SELECT style, Color,  from sodetail

  --***This does not work , how can make this work .

2. How can I get a current PID of a connection?

3. Set a variable to equal a select statement containing variables

4. BLOB / TEXT Field and SQL

5. Pass a variable as part of an SQL statement

6. Do you know of a HTML -> Java scripting language?

7. pass variable in 'include' statement

8. Disconnected Recordsets using a Command Object

9. How to pass variables to select statement

10. Passing a variable to a sql statement

11. Passing a variable to a SQL statement from Visual J++

12. Problems passing a string variable to an SQL statement

13. Pass a variable as part of an SQL statement