Can't Assign to Array

X

XMan

I've got this message of "Can't assign to array" with this code:

Private Sub Form_Load()
Dim arTest() As String

arTest = Split(Me.OpenArgs, ",")
End Sub

Am I missing something here? TIA.
 
D

Dirk Goldgar

XMan said:
I've got this message of "Can't assign to array" with this code:

Private Sub Form_Load()
Dim arTest() As String

arTest = Split(Me.OpenArgs, ",")
End Sub

Am I missing something here? TIA.


Works for me, provided that OpenArgs isn't Null. What version of Access
are you using? Split() was introduced with Access 2000, so if you're
using Access 97 you have to write your own version. Do you have Option
Explicit set for the module?
 
X

XMan

I'm using Access97 and got the code for Split() function.

What I've found to work is to declare the array as Variant like this

Dim arTest As Variant

and it works.

Thanks for your help.
 
D

Dirk Goldgar

XMan said:
I'm using Access97 and got the code for Split() function.

What I've found to work is to declare the array as Variant like this

Dim arTest As Variant

and it works.

Thanks for your help.

Probably the function code you got returns a Variant, not an array,
unlike the VB6 Split() function. Anyway, since you've got it working,
all is well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top