Solved

add item to array in vba

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now