Group:  Microsoft Access ยป microsoft.public.access.modulesdaovba.ado
Thread: Can't use Byte datatype for Recordset Index?

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Can't use Byte datatype for Recordset Index?
"GY2" <2muchspam[ at ]wherever.com> 01.02.2006 16:19:56
The following code won't run for me in an Access module apparently because J
is dimmed As Byte. The code runs fine with J As Integer or As Variant. Just
curious but is this right?

Sub RecordsetTest()

Dim J As Byte

Dim rs As adodb.recordset
Dim cnn As adodb.Connection

Set rs = New adodb.recordset
Set cnn = CurrentProject.Connection

rs.Open "tblWhatever", cnn

Let J = 2
Debug.Print rs(2)
Debug.Print rs(J) 'This will blowup with Dim J as Byte

End Sub


Re: Can't use Byte datatype for Recordset Index?
John Nurick <j.mapSoN.nurick[ at ]dial.pipex.com> 01.02.2006 19:47:27
I can reproduce this. Using fuller syntax makes no difference:
Debug.Print rs.Fields.Item(J).Value

But it's so trivial that I'm inclined to think of it as a lacuna in the
documentation rather than a bug. I can't think of any good reason to use
Byte as an iterator variable on a 32-bit system.

BTW, it doesn't affect DAO.Recordset.

On Wed, 1 Feb 2006 11:19:56 -0500, "GY2" <2muchspam[ at ]wherever.com> wrote:

[Quoted Text]
>
>The following code won't run for me in an Access module apparently because J
>is dimmed As Byte. The code runs fine with J As Integer or As Variant. Just
>curious but is this right?
>
>Sub RecordsetTest()
>
> Dim J As Byte
>
> Dim rs As adodb.recordset
> Dim cnn As adodb.Connection
>
> Set rs = New adodb.recordset
> Set cnn = CurrentProject.Connection
>
> rs.Open "tblWhatever", cnn
>
> Let J = 2
> Debug.Print rs(2)
> Debug.Print rs(J) 'This will blowup with Dim J as Byte
>
>End Sub
>
>

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

Re: Can't use Byte datatype for Recordset Index?
"GY2" <2muchspam[ at ]wherever.com> 01.02.2006 20:51:25
Thanks for checking it out. Still kind of interesting to me.

"John Nurick" <j.mapSoN.nurick[ at ]dial.pipex.com> wrote in message
news:v432u19334qsr8ijtihbvo7k3e5jek69qd[ at ]4ax.com...
[Quoted Text]
>I can reproduce this. Using fuller syntax makes no difference:
> Debug.Print rs.Fields.Item(J).Value
>
> But it's so trivial that I'm inclined to think of it as a lacuna in the
> documentation rather than a bug. I can't think of any good reason to use
> Byte as an iterator variable on a 32-bit system.
>
> BTW, it doesn't affect DAO.Recordset.
>
> On Wed, 1 Feb 2006 11:19:56 -0500, "GY2" <2muchspam[ at ]wherever.com> wrote:
>
>>
>>The following code won't run for me in an Access module apparently because
>>J
>>is dimmed As Byte. The code runs fine with J As Integer or As Variant.
>>Just
>>curious but is this right?
>>
>>Sub RecordsetTest()
>>
>> Dim J As Byte
>>
>> Dim rs As adodb.recordset
>> Dim cnn As adodb.Connection
>>
>> Set rs = New adodb.recordset
>> Set cnn = CurrentProject.Connection
>>
>> rs.Open "tblWhatever", cnn
>>
>> Let J = 2
>> Debug.Print rs(2)
>> Debug.Print rs(J) 'This will blowup with Dim J as Byte
>>
>>End Sub
>>
>>
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>


Re: Can't use Byte datatype for Recordset Index?
<david[ at ]epsomdotcomdotau> 01.02.2006 22:11:02
d---d c/c++ code wackers. I'm afraid it doesn't occur
to them to include systematic type casting, and if it did,
they would think it was a concession to end-user incompetence.

They have a very self-righteous (and laughably ignorant)
view of language design.

(david)


"John Nurick" <j.mapSoN.nurick[ at ]dial.pipex.com> wrote in message
news:v432u19334qsr8ijtihbvo7k3e5jek69qd[ at ]4ax.com...
[Quoted Text]
> I can reproduce this. Using fuller syntax makes no difference:
> Debug.Print rs.Fields.Item(J).Value
>
> But it's so trivial that I'm inclined to think of it as a lacuna in the
> documentation rather than a bug. I can't think of any good reason to use
> Byte as an iterator variable on a 32-bit system.
>
> BTW, it doesn't affect DAO.Recordset.
>
> On Wed, 1 Feb 2006 11:19:56 -0500, "GY2" <2muchspam[ at ]wherever.com> wrote:
>
> >
> >The following code won't run for me in an Access module apparently
because J
> >is dimmed As Byte. The code runs fine with J As Integer or As Variant.
Just
> >curious but is this right?
> >
> >Sub RecordsetTest()
> >
> > Dim J As Byte
> >
> > Dim rs As adodb.recordset
> > Dim cnn As adodb.Connection
> >
> > Set rs = New adodb.recordset
> > Set cnn = CurrentProject.Connection
> >
> > rs.Open "tblWhatever", cnn
> >
> > Let J = 2
> > Debug.Print rs(2)
> > Debug.Print rs(J) 'This will blowup with Dim J as Byte
> >
> >End Sub
> >
> >
>
> --
> John Nurick [Microsoft Access MVP]
>
> Please respond in the newgroup and not by email.
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net