Solved

add item to array in vba

Posted on 2014-10-02
1
270 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 500 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

Industry Leaders: 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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

691 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