Solved

Declare string array in one line

Posted on 2013-12-27
4
388 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

777 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