Re: getrows in VB

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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]
>
.



Relevant Pages

  • Re: Character String Operation
    ... Now this confuses me. ... What are you doing writing to the string? ... correspondingly strange values in the string. ... Think of internal READ/WRITE as just like READ/WRITE to an ordinary ...
    (comp.lang.fortran)
  • set to edittext
    ... logicals. ... confuses me! ... set(handles.edit_mat, 'String', '/home') ... Is there another way to proceed with edittext? ...
    (comp.soft-sys.matlab)
  • Re: How to send struct data over socket?
    ... > structure into a long string, but the part that still confuses is once ... > the long string is transmitted over the socket, ... But be aware that you should eval strings only when you know where they ...
    (comp.lang.perl.misc)
  • Re: Empty cell and a the empty String
    ... A null string is a value. ... Empty cell: ... XL confuses the issue by clearing the cell if a null string is ...
    (microsoft.public.excel.programming)
  • Re: Locating the First Comma in a Text
    ... data>text to columns>pretty self explanatory ... Don Guillett ... a text string, and then the next, until there is no more. ... Becasue I have ...
    (microsoft.public.excel.worksheet.functions)