Solved

Declare string array in one line

Posted on 2013-12-27
4
387 Views
Last Modified: 2013-12-27
Hi

I am trying to make this work in Microsoft Access 2013.  (see below.)  
I would like declare a defined array very much like the second line of the code.

Thank you.

Dim fileNameArray() As String
   fileNameArray = Array("a", "b", "c", "d", "e")

Open in new window

0
Comment
Question by:peispud
  • 2
4 Comments
 
LVL 24

Expert Comment

by:Bitsqueezer
ID: 39742940
Hi,

that's not possible as the Array function only produces variant arrays. That gives you the possibility to create mixed datatype arrays but for the price that you can't create string arrays with this function. So your code works with this if you can live with using variants:
Dim fileNameArray() As Variant
   fileNameArray = Array("a", "b", "c", "d", "e")

Open in new window


Cheers,

Christian
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39742955
but you could do:

Dim FilenameArray() as string

FilenameArray = Split("a,b,c,d,e", ",")
0
 

Author Closing Comment

by:peispud
ID: 39742968
Both answers were correct,  but you NAILED it Mr Fye.

I wasn't aware of the split function.  Perfect!

Thank you
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39742971
glad I could help.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

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…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
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 “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

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

14 Experts available now in Live!

Get 1:1 Help Now