Re: getrows in VB
- From: "dave" <dave@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 28 Dec 2005 06:21:04 -0800
Thanks for all these answers i guess i wasn't clear about what was going on
becasue the thing that confuses me about the null error is that the data
shouldn't be null. data(2,i) should contain a string but when GetRows
retrieves the data from the table it makes it null at data(2,4) and ignores
the next row of data in the table. though thanks for the tip on using &
instead of + i will look further into that.
"Marshall Barton" wrote:
> dave wrote:
>
> >Hello i'm trying to read data from a table in a loop and put it in a long
> >string so i have code that looks like this
> >
> >data() = Records.GetRows(Records.Properties.Count)
> >
> > For i = 0 To Records.RecordCount
> >
> > outputString = outputString + "|"
> > outputString = outputString + CStr(data(0, i))
> > outputString = outputString + "|"
> > outputString = outputString + CStr(data(1, i))
> > outputString = outputString + "|"
> > outputString = outputString + CStr(data(2, i))
> >
> > Next
> >
> >This all looks good to me however there are two problems
> >
> >1) it only reads the first 5 records ignoring the 6th record
> >
> >2) uppon reaching data(2,4) it contains Null and i get an illegal use of
> >Null error
>
>
> A rather strange thing to do, but the big problem with your
> code is that Null propagates across the + operator. You
> should use the & operator instead.
>
> The actual error you got was because CStr() does not allow
> for a Null value. The Str() function does allow for Null,
> but it also adds a space character in front of positive
> numbers and it does not accept strings. You may prefer to
> use CStr(Nz(data(x,i),"")
>
> OTOH, Access will cast the data value automaticallym so you
> can get away with just using:
>
> outputString = outputString & data(2, i)
>
> --
> Marsh
> MVP [MS Access]
>
.
- Follow-Ups:
- Re: getrows in VB
- From: Marshall Barton
- Re: getrows in VB
- References:
- Re: getrows in VB
- From: Marshall Barton
- Re: getrows in VB
- Prev by Date: Re: Call Syntax
- Next by Date: Re: Call Syntax
- Previous by thread: Re: getrows in VB
- Next by thread: Re: getrows in VB
- Index(es):
Relevant Pages
|