Link to home
Start Free TrialLog in
Avatar of Ignis2000
Ignis2000

asked on

Strange behaviour with ADO Recordset

I have a subroutine which copies data from a recordset into a range. I wrote this to avoid using CopyFroMRecordset as that function doesn't allow you to change the columns in the target area. This function takes the name of the column from the heading and gets the value by a rds.fields(<Name>).

Has been working quite well all this while (few months) and now I've run into a strange error. For some fields alone, it gives a NULL value when referred to by name like this:

rngCopy.Cells(intRow, intIx) = rds.Fields(varCols(1, intIx)) ' = Null

On the Immediate window

?rds.fields("fkIssuer")
Null
?rds.Fields(0).name
fkIssuer
?rds.fields(0)
20

It gives a null value when referred to by name and the real value when referred to by ordinal! Anyone else have this problem??

Am stumped!

Thanks guys!!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

please run this:
?rds.Fields(0).name & "<" 
maybe there is some space after the "name"? 

Open in new window

Avatar of Ignis2000
Ignis2000

ASKER

Nope! Already tried.

?rds.Fields(0).name & "<"
fkIssuer<
?strcomp(varcols(1,intix),rds.Fields(0).Name)
 0
Curious! What do you get with:
?rds.Fields(rds.Fields(0).Name)
and what if you specify .Value?

?rds.Fields(rds.Fields(0).Name)
Null

?rds.Fields(0).Value
 1
?rds.Fields(rds.Fields(0).Name).Value
Null

Nothing again. I know. never come across this before.totally strange! And it doesn't work only for some fields!!
The problem atleast in this one query seems to be with bigint fields. Char fields work fine.

output.jpg
Never seen or heard of that before. How about:
?CStr(rds.fields("fkIssuer"))

ASKER CERTIFIED SOLUTION
Avatar of Ignis2000
Ignis2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the update - glad you got it fixed!