Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / May 2005

Tip: Looking for answers? Try searching our database.

Problems with array in module (Access '97)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nick - 31 May 2005 19:17 GMT
Hi,

I'm having some troubles using a string array in a module in VBA.  I can
dimension the string array but am unable to set the variables equal to a
constant within the module (Really needs to be in the module).  Actual code
(all two lines of it) is near the end.

When I try to set   strStep1(1) = "Description"   by using 'Set' or 'Let'
it gives an error (Invalid outside procedure), and when I try using 'Const'
declaration, an error is generated when the program gets to the
parenthesis.  

Public strStep1(10) As String

Set strStep1(1) = "Description"  'Invalid outside procedure
-or-
Public Const strStep(1) as string = "Description"  'Gets to '(' and expects
'As' or '='

Any help would be appreciated, post back if clarification is needed.

Thanks,

Nick
Marshall Barton - 31 May 2005 20:18 GMT
>I'm having some troubles using a string array in a module in VBA.  I can
>dimension the string array but am unable to set the variables equal to a
[quoted text clipped - 12 lines]
>Public Const strStep(1) as string = "Description"  'Gets to '(' and expects
>'As' or '='

In this case, the error message means exactly what it says.

Move the array initialization to a procedure that you can
call at the appropriate time.

Don't use Set, it's for objects.  Either use Let (archaric)
or nothing (standard):

Public Sub InitArray()
    strStep1(1) = "Description"
End Sub

Signature

Marsh
MVP [MS Access]

Nick - 31 May 2005 21:00 GMT
Thanks Marshall, I had overlooked the obvious... Thanks for steering me
back.  I tend to overcomplicate my programs if I'm not careful.

Thanks again,

Nick
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.