Re: Accessing a table field
am 17.10.2007 03:16:53 von Bob Quintal
"Jerry West" wrote in
news:13haq9uj3bl3958@news.supernews.com:
> I'm using VB6 and ADO. I have connected to a database and can look
> at some fields like so:
>
> Do Until adoRecordset.EOF
>
> sTmp$ = adoRecordset!Cost
> adoRecordset.MoveNext
>
> Loop
>
> The fields that I cannot access are those fields which have spaces
> in them. In the example above I have no trouble accessing the
> "Cost" field. But there is another field titled "Product ID". When
> I do the following I get an error:
>
> Do Until adoRecordset.EOF
>
> sTmp$ = adoRecordset!Product ID
> adoRecordset.MoveNext
>
> Loop
>
> Obviously the space in the field name is illegal. How does one
> access field names with spaces in them?
>
> Thanks!
>
> JW
>
Delimit the field names with [ and ], or refer to the fields as
sTmp$ = adoRecordset.fields("Product ID")
or rename the fields to remove the illegal characters.
--
Bob Quintal
PA is y I've altered my email address.
--
Posted via a free Usenet account from http://www.teranews.com
Accessing a table field
am 17.10.2007 03:45:33 von Jerry West
I'm using VB6 and ADO. I have connected to a database and can look at some
fields like so:
Do Until adoRecordset.EOF
sTmp$ = adoRecordset!Cost
adoRecordset.MoveNext
Loop
The fields that I cannot access are those fields which have spaces in them.
In the example above I have no trouble accessing the "Cost" field. But there
is another field titled "Product ID". When I do the following I get an
error:
Do Until adoRecordset.EOF
sTmp$ = adoRecordset!Product ID
adoRecordset.MoveNext
Loop
Obviously the space in the field name is illegal. How does one access field
names with spaces in them?
Thanks!
JW
Re: Accessing a table field
am 17.10.2007 04:21:49 von Salad
Jerry West wrote:
> I'm using VB6 and ADO. I have connected to a database and can look at some
> fields like so:
>
> Do Until adoRecordset.EOF
>
> sTmp$ = adoRecordset!Cost
> adoRecordset.MoveNext
>
> Loop
>
> The fields that I cannot access are those fields which have spaces in them.
> In the example above I have no trouble accessing the "Cost" field. But there
> is another field titled "Product ID". When I do the following I get an
> error:
>
> Do Until adoRecordset.EOF
>
> sTmp$ = adoRecordset!Product ID
> adoRecordset.MoveNext
>
> Loop
>
> Obviously the space in the field name is illegal. How does one access field
> names with spaces in them?
>
> Thanks!
>
> JW
>
>
In VBA we surround the field with []. Example
adoRecordset![Product ID]
I'm not keep with spaces in field names.
Re: Accessing a table field
am 17.10.2007 06:30:50 von Jerry West
Hey, that worked!!
Thanks!
JW
"Salad" wrote in message
news:13hasdu1lur6jea@corp.supernews.com...
> Jerry West wrote:
>> I'm using VB6 and ADO. I have connected to a database and can look at
>> some fields like so:
>>
>> Do Until adoRecordset.EOF
>>
>> sTmp$ = adoRecordset!Cost
>> adoRecordset.MoveNext
>>
>> Loop
>>
>> The fields that I cannot access are those fields which have spaces in
>> them. In the example above I have no trouble accessing the "Cost" field.
>> But there is another field titled "Product ID". When I do the following I
>> get an error:
>>
>> Do Until adoRecordset.EOF
>>
>> sTmp$ = adoRecordset!Product ID
>> adoRecordset.MoveNext
>>
>> Loop
>>
>> Obviously the space in the field name is illegal. How does one access
>> field names with spaces in them?
>>
>> Thanks!
>>
>> JW
> In VBA we surround the field with []. Example
> adoRecordset![Product ID]
>
> I'm not keep with spaces in field names.