General discussion

Locked

Array Declaration in VB 6.0

By afisher ·
When I try to specify the upperbound of strValues by referencing tempRS's record count property I get a subscript out of range error. Any suggestions?

Dim tempRS As Recordset
Dim intUpperbound As Integer
Dim i As Integer
Dim strValues() As String
Dim strSQL As String
Set tempRS = New Recordset
strSQL = "SELECT tblContacts.CAddress FROM tblContacts;"
tempRS.Open strSQL, CN, adOpenDynamic, adLockOptimistic
ReDim strValues(0 To tempRS.RecordCount - 1) As String

This conversation is currently closed to new comments.

4 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Array Declaration in VB 6.0

by afisher In reply to Array Declaration in VB 6 ...

Also, the SQL statement runs fine in Access (my back end) and the connection is open and working fine when referenced by other procedures.

Collapse -

Array Declaration in VB 6.0

by mpalazzo In reply to Array Declaration in VB 6 ...

What's the value of your tempRS.RecordCount? I'll bet it's -1 which would indicate that the record count property is unavailable due to either your cursor type (which looks okay to me) or the data provider not being able to return the number of records. One solution might be to open the rs before you redim the array, move to the last record and then store the absolute record position in a variable (long). Then just redim your array using the variable as the ubound instead of using the recordcount property.

Did that help? :)

Collapse -

Array Declaration in VB 6.0

by afisher In reply to Array Declaration in VB 6 ...

Thank you. That cleared up my problem.

Collapse -

Array Declaration in VB 6.0

by afisher In reply to Array Declaration in VB 6 ...

This question was closed by the author

Back to Web Development Forum
4 total posts (Page 1 of 1)  

Related Discussions

Software Forums