How do I use contents of variable as field name(db!rst!variable) 
Author Message
 How do I use contents of variable as field name(db!rst!variable)

When I try to use a variable to hold changing field names in a loop
(fieldname1,fieldname2,etc.) VBA returns a error message that it cannot
locate the column with the name (myvariable). How do I make it read the
contents of the variable instead of the variable name itself ?

Thanks



Sat, 17 Feb 2001 03:00:00 GMT  
 How do I use contents of variable as field name(db!rst!variable)

Quote:
> When I try to use a variable to hold changing field names in a loop
> (fieldname1,fieldname2,etc.) VBA returns a error message that it cannot
> locate the column with the name (myvariable). How do I make it read the
> contents of the variable instead of the variable name itself ?

rst.Fields("FieldName" & i)

or

rst("FieldName" & i)

will do it. -- Ken



Sat, 17 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using Variables for Field Names using .AddNew and .Update

2. Using variable to refer to variable name?

3. Using variables for field names in recordset

4. Using variables instead of field names

5. using a variable to specify field name in dlookup function

6. referencing field names using a variable

7. Using variables for field names in VBA

8. Field Names using variables

9. Repost Code Example - using variables in field name references

10. Repost Code Example - using variables in field name references

11. Adding a record using the field names as a variable

12. Selecting Field Values with a VARIABLE field name

 

 
Powered by phpBB® Forum Software