473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

VBA breakout

I'm having an issue with an error I am getting with the following code
in Access 2002.

Sub AddCategories()

Dim rst As DAO.Recordset
Dim i As Integer

Set rst = CurrentDb.OpenRecordset("SortCat")
rst.AddNew
Do While strCat(i) <"" **** error occurs here

rst.AddNew

rst!Sort_Cat = strCat(i)

rst.Update

i = i + 1

Loop
The strCat is an array that is defined publicly and filled from a
function that calls this one. I get a "subscript out of range" error
once the array is empty. It is a dynamic array due to it taking
information from a split string with a random number of items
(categories from outlook). I've tried many ways to break out of the
loop. What test can I do to be able to break out of the loop and go
back to the previous function?

Thanks

O
Mar 21 '07 #1
3 5530
Facilitator,

You might want to check to see if your itterator is within the boundaries of
the array. Something like this.

If i < LBound(strCat) or i UBound(strCat) then Exit Do

-- Bill
"The Facilitator" <fa*******@yahoo.comwrote in message
news:mk********************************@4ax.com...
I'm having an issue with an error I am getting with the following code
in Access 2002.

Sub AddCategories()

Dim rst As DAO.Recordset
Dim i As Integer

Set rst = CurrentDb.OpenRecordset("SortCat")
rst.AddNew
Do While strCat(i) <"" **** error occurs here

rst.AddNew

rst!Sort_Cat = strCat(i)

rst.Update

i = i + 1

Loop
The strCat is an array that is defined publicly and filled from a
function that calls this one. I get a "subscript out of range" error
once the array is empty. It is a dynamic array due to it taking
information from a split string with a random number of items
(categories from outlook). I've tried many ways to break out of the
loop. What test can I do to be able to break out of the loop and go
back to the previous function?

Thanks

O

Mar 21 '07 #2
That was exactly what I needed.

Thank you VERY much.

O

On Tue, 20 Mar 2007 17:50:16 -0700, "AlterEgo"
<al********@dslextreme.comwrote:
>Facilitator,

You might want to check to see if your itterator is within the boundaries of
the array. Something like this.

If i < LBound(strCat) or i UBound(strCat) then Exit Do

-- Bill
"The Facilitator" <fa*******@yahoo.comwrote in message
news:mk********************************@4ax.com.. .
>I'm having an issue with an error I am getting with the following code
in Access 2002.

Sub AddCategories()

Dim rst As DAO.Recordset
Dim i As Integer

Set rst = CurrentDb.OpenRecordset("SortCat")
rst.AddNew
Do While strCat(i) <"" **** error occurs here

rst.AddNew

rst!Sort_Cat = strCat(i)

rst.Update

i = i + 1

Loop
The strCat is an array that is defined publicly and filled from a
function that calls this one. I get a "subscript out of range" error
once the array is empty. It is a dynamic array due to it taking
information from a split string with a random number of items
(categories from outlook). I've tried many ways to break out of the
loop. What test can I do to be able to break out of the loop and go
back to the previous function?

Thanks

O
Mar 21 '07 #3
BTW, if you've the time, Bill...I've a third (and last post for
tonight) that I could definitely use help with. It is a bit more
complicated, though.

O
On Tue, 20 Mar 2007 20:56:33 -0400, The Facilitator
<fa*******@yahoo.comwrote:
>That was exactly what I needed.

Thank you VERY much.

O

On Tue, 20 Mar 2007 17:50:16 -0700, "AlterEgo"
<al********@dslextreme.comwrote:
>>Facilitator,

You might want to check to see if your itterator is within the boundaries of
the array. Something like this.

If i < LBound(strCat) or i UBound(strCat) then Exit Do

-- Bill
"The Facilitator" <fa*******@yahoo.comwrote in message
news:mk********************************@4ax.com. ..
>>I'm having an issue with an error I am getting with the following code
in Access 2002.

Sub AddCategories()

Dim rst As DAO.Recordset
Dim i As Integer

Set rst = CurrentDb.OpenRecordset("SortCat")
rst.AddNew
Do While strCat(i) <"" **** error occurs here

rst.AddNew

rst!Sort_Cat = strCat(i)

rst.Update

i = i + 1

Loop
The strCat is an array that is defined publicly and filled from a
function that calls this one. I get a "subscript out of range" error
once the array is empty. It is a dynamic array due to it taking
information from a split string with a random number of items
(categories from outlook). I've tried many ways to break out of the
loop. What test can I do to be able to break out of the loop and go
back to the previous function?

Thanks

O
Mar 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dr. International | last post by:
Did You Know: a.. By 2010, emerging PC markets like China, Russia and India will add 566 million new PCs. (Source: Forrester Research) b.. Web users are up to four times more likely to...
7
by: deko | last post by:
I have a function with a number of long loops. While the function is running, I want to be able to click a Stop button and exit the function as quickly as possible. The abbreviated code looks...
6
by: Tim Barg | last post by:
I am using a CryptoStream to encrypt and then save an xml file. However, when reading it back in, I am getting a CryptographicException. I am hitting this because I have some large xml files ( >...
69
by: markarichman | last post by:
Why is Firefox complaining with this error: ------------------------------------------------------------ missing ) after argument list setTimeout('breakOut',5000);...
0
by: lazaridis_com | last post by:
For a larger scale project, a collaboration infrastructure and toolset should be selected. More information about the overall project: http://lazaridis.com/pj The actually active system is...
5
by: Charles May | last post by:
Anyone have a simple concept for the best way to store timeclock information in a database. I currently have my table set up like this with a typical daily entry. tcID empID Type ...
5
by: A. Farber | last post by:
Hello, I'm trying to print out a const char* buffer by first printing 16 bytes as hex codes, then printing them again as characters or dots (if they aren't printable) and so on: 20 A5 96 74...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.