Hi, I'm relatively new to VBA (6.3) but have many years coding experience in other languages.
I'm executing an ACCESS SQL query from VBA which returns a single record with fields names C1, C2 ..... C12.
I'd like to assign the (numeric) values from these fields to elements of an array.
Rather than writing simple code such as:
I'd like to do something like:
But I get "Error number 13: Type mismatch" when I run it. I've experimented with CInt and CStr conversion functions but to no avail. I assume I am not able to form the field name !C1 etc and get VBA to interpret it as such!
Is there a (better) way to do this?
Best Regards, Phil
I'm executing an ACCESS SQL query from VBA which returns a single record with fields names C1, C2 ..... C12.
I'd like to assign the (numeric) values from these fields to elements of an array.
Rather than writing simple code such as:
Code:
Dim Poprange(11) As Integer poprange(0) = !C1 poprange(1) = !C2 .. poprange(11) = !C12
Code:
Dim I As Integer Dim Poprange(11) As Integer For I = 0 To 11 suffix = CStr(I + 1) Poprange(I) = "!C" & suffix Next
Is there a (better) way to do this?
Best Regards, Phil
Comment