?
Solved

add item to array in vba

Posted on 2014-10-02
1
Medium Priority
?
288 Views
Last Modified: 2014-10-02
I am looping through a recordset and where an instr is found I want to add that item to aliasarray but it wont allow, i am not sure how do deal with this as the size of the array is as of yet unknown  

I thought referencing it directly it would add the string.
Do Until RstAlias.EOF
           
            If InStr(Me.[DecodeResult].Value, .Fields("sClientDescGroup").Value) <> 0 Then
           
                AliasArray(index) = .Fields("sDesc").Value
                index = index + 1
            Else
           
           
            End If
       
       
       
        .MoveNext
        Loop
0
Comment
Question by:PeterBaileyUk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 2000 total points
ID: 40357636
Try using Redim Preserve AliasArray(Index +1) as [datatype] before trying to assign a value to a position in the array.

so it would look like this
Redim Preserve AliasArray(Index +1)  as [datatype]
AliasArray(index) = .Fields("sDesc").Value
index = index + 1

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question