Avatar of peispud
peispud
Flag for Canada asked on

Declare string array in one line

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

Microsoft Access

Avatar of undefined
Last Comment
Dale Fye

8/22/2022 - Mon
Bitsqueezer

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
ASKER CERTIFIED SOLUTION
Dale Fye

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
peispud

ASKER
Both answers were correct,  but you NAILED it Mr Fye.

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

Thank you
Dale Fye

glad I could help.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes