LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Why is this returning a Ubound value of zero

I'm trying to use a variant array in a For next statement and I can't
get the UBound of the variant array.

Any time I run this, l comes back as 0. But if i transpose the array
and add it to a listbox on a form, I get the data I'm looking for. How
does an array have elements contained within, but have a UBound of 0?

Code posted below

' Constant declarations
Const dbPath = "C:\XXXXXXXXXXX.mdb"
Const sConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dbPath & ";"

' Variable declarations
Dim sTitle As String
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim rcArray As Variant
Dim sArray() As String
Dim sSQL As String
Dim j As Long, l As Long

' Get batch title
sTitle = frmSelection.cboBatch.Value

' Build the SQL query.
sSQL = "SELECT [tbl RBT Ladder Batches].PrnNo " _
& "FROM [tbl RBT Ladder Batches] " _
& "WHERE ((([tbl RBT Ladder Batches].Title) = """ & sTitle
& """)) " _
& "ORDER BY [tbl RBT Ladder Batches].PrnNo;"

'Open connection to the database
cnt.Open sConnect

'Open recordset and copy to an array
rst.Open sSQL, cnt
rcArray = rst.GetRows()

'Get the number of elements in the array
l = UBound(rcArray)

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM
UDF returning #VALUE! why? Adam Kroger Excel Discussion (Misc queries) 7 December 18th 05 09:43 PM
=if returning 0 Jim Excel Worksheet Functions 4 December 15th 05 07:09 PM
Need some help returning a value rcarrollct Excel Worksheet Functions 2 July 6th 05 11:36 PM
Returning more than one value DunderMifflin Excel Discussion (Misc queries) 4 May 31st 05 04:40 AM


All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"