PC Review


Reply
Thread Tools Rate Thread

Run-time error '9' when calling LBound on a dynamic array

 
 
paul.schrum@gmail.com
Guest
Posts: n/a
 
      30th Jul 2011
Access 2007

I am getting a "subscript out of range" error when using LBound on a
dynamic array which I just ReDim'd.

<code>
Dim ad_aveGallonsPerDay() As Double ' ad_ stands for Array of
Doubles
ReDim da_aveGallonsPerDay(2 To 12)
Dim testLB As Long, testUB As Long
testLB = LBound(ad_aveGallonsPerDay) ' error occurs at this line
</code>

Can anyone help me figure out what I should do differently?

Thanks.
- Paul Schrum
 
Reply With Quote
 
 
 
 
Stuart McCall
Guest
Posts: n/a
 
      30th Jul 2011

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Access 2007
>
> I am getting a "subscript out of range" error when using LBound on a
> dynamic array which I just ReDim'd.
>
> <code>
> Dim ad_aveGallonsPerDay() As Double ' ad_ stands for Array of
> Doubles
> ReDim da_aveGallonsPerDay(2 To 12)


Typo: Should be ReDim ad_aveGallonsPerDay(2 To 12)

> Dim testLB As Long, testUB As Long
> testLB = LBound(ad_aveGallonsPerDay) ' error occurs at this line
> </code>
>
> Can anyone help me figure out what I should do differently?
>
> Thanks.
> - Paul Schrum
>



 
Reply With Quote
 
 
 
 
Tony Toews
Guest
Posts: n/a
 
      31st Jul 2011
On Sat, 30 Jul 2011 10:15:59 -0700 (PDT), "(E-Mail Removed)"
<(E-Mail Removed)> wrote:

As Stuart points out there's a typo present but to add to his reply.

(It leaped right out at me but then I've been programming for 30+
years so maybe my brain does that automatically how.)

Ensure you have Option Explicit at the top of all code modules
including forms and reports as well as VBA.

Also in the VBA editor Tools >> Options and check the Require Variable
Declaration check box. This will ensure all new forms, reports and
modules have the Option Explicit line.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Array Lbound not working when only one value in array dean.brunne@lion-nathan.com.au Microsoft Excel Programming 3 25th May 2007 04:08 AM
Moving into a cell range using Offset and LBound =?Utf-8?B?VElTUg==?= Microsoft Excel Programming 2 26th Mar 2006 11:56 PM
Change LBound of array R Avery Microsoft Excel Programming 4 19th May 2005 04:53 PM
LBound and UBound question Starbuck Microsoft VB .NET 2 25th Jan 2005 08:57 AM
Ubound & Lbound Michael168 Microsoft Excel Programming 3 1st Jun 2004 02:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:57 AM.