By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,616 Members | 2,026 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,616 IT Pros & Developers. It's quick & easy.

VBA breakout

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.