Can't use Byte datatype for Recordset Index?

G

GY2

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
 
J

John Nurick

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

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top