How do i represent a string as a column name?
example: COLUMN_NAME = "SALES_10"
My Code:
dim i as integer
dim sStr as string
i = 10
sStr = "SALES_" & trim(str(i))
rs(sStr) = 9999 => this is ok
rs.update => generates an error
Printable View
How do i represent a string as a column name?
example: COLUMN_NAME = "SALES_10"
My Code:
dim i as integer
dim sStr as string
i = 10
sStr = "SALES_" & trim(str(i))
rs(sStr) = 9999 => this is ok
rs.update => generates an error
It is unclear what you want to do:
- build a string
- "represent a string" (???)
or update your recordset.
Please explain.
Roy
"Rob" <rphildawa@yahoo.com> wrote in message news:3cfae37a$1@10.1.10.29...
>
> How do i represent a string as a column name?
>
> example: COLUMN_NAME = "SALES_10"
>
> My Code:
>
> dim i as integer
> dim sStr as string
>
> i = 10
> sStr = "SALES_" & trim(str(i))
> rs(sStr) = 9999 => this is ok
> rs.update => generates an error
"Rob" <rphildawa@yahoo.com> wrote:
>
>How do i represent a string as a column name?
>
>example: COLUMN_NAME = "SALES_10"
>
>My Code:
>
>dim i as integer
>dim sStr as string
>
>i = 10
>sStr = "SALES_" & trim(str(i))
>rs(sStr) = 9999 => this is ok
>rs.update => generates an error
From what I see your "rs(sStr)" reference is perfectly fine. The "rs.update"
is failing for reasons not associated to the sStr usage. What error message
is being returned?
Guy Smith
Hi Guy!
The error says "Invalid Column Name" or something. I don't know how to substitute
a string as a column name. In clipper, i just place an ampersand (&) to
the variable in order to refer to its content. how do i do this in VB?
Thanks a lot for ur help.
"Guy Smith" <sf@afddsf.com> wrote:
>
>"Rob" <rphildawa@yahoo.com> wrote:
>>
>>How do i represent a string as a column name?
>>
>>example: COLUMN_NAME = "SALES_10"
>>
>>My Code:
>>
>>dim i as integer
>>dim sStr as string
>>
>>i = 10
>>sStr = "SALES_" & trim(str(i))
>>rs(sStr) = 9999 => this is ok
>>rs.update => generates an error
>
>From what I see your "rs(sStr)" reference is perfectly fine. The "rs.update"
>is failing for reasons not associated to the sStr usage. What error message
>is being returned?
>
>Guy Smith