Concatenating field name 
Author Message
 Concatenating field name

I have a drop down on a form that has different field
names that a person can export some data by.  For example,
if they would like to export by Country, they would select
country and the data would be exported to excel by all the
unique countries in the database.  I am trying to cut my
code size down and would like to do the following (if
possible)

code = "rst![" & ExportByValue & "]"
                 (Country Name)
instead of code = rst![Country]

What happens though is it looks at the above as a string
instead of getting the actual country field value.

I know in Excel you can do the following to build a
controls name:  OLEObjects("OptionButton" & number).Object

Is there anything similar in Access???



Tue, 09 Aug 2005 00:01:52 GMT  
 Concatenating field name


Quote:
>I have a drop down on a form that has different field
>names that a person can export some data by.  For example,
>if they would like to export by Country, they would select
>country and the data would be exported to excel by all the
>unique countries in the database.  I am trying to cut my
>code size down and would like to do the following (if
>possible)

>code = "rst![" & ExportByValue & "]"
>                 (Country Name)
>instead of code = rst![Country]

>What happens though is it looks at the above as a string
>instead of getting the actual country field value.

>I know in Excel you can do the following to build a
>controls name:  OLEObjects("OptionButton" & number).Object

>Is there anything similar in Access???

Use the syntax

code = rst.Fields(ExportByValue)

assuming that ExportByValue is a Text string containing the fieldname.

                  John W. Vinson[MVP]    
    Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=public



Tue, 09 Aug 2005 01:53:31 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Concatenate a field name

2. Having trouble accessing single field key with two concatenated fields

3. Concatenating a Text Field and a Number Field

4. Concatenated Variable Names

5. Concatenating variable names

6. applying ital to selected fields within a concatenated textbox

7. Concatenating Fields in sql-string in vba

8. Trouble concatenating multiple rows from one field

9. Bolding text in concatenated fields

10. Concatenate two fields to one usable variable

11. Custom fields: concatenating project & task strings

12. Problem Opening Recordset with two fields concatenated As

 

 
Powered by phpBB® Forum Software