-
I have declared my fixed array in a module.bas file
but when i try to run it i get an error "subscript out of
range"
run time error "9"
any ideas what im doing wrong???
Code:
Option Explicit
Public outSkillsData()
then tried using my array called outskillsdata
Code:
Dim noData As Boolean
noData = False
On Local Error Resume Next
If UBound(outSkillsData, 2) = 0 Then noData = True
On Local Error GoTo 0
help me what am i doing wrong?????
-
Your Error with Arrays
Hi JohnnyBoy
The problem is that the array is not declared correctly. If it is a fixed array it needs to have the length inside the brackets ie,
Public outSkillsData(10)
What you have done is declare a dynamic array. Using this technique you need to redim the array befor you use it, ie
ReDim outSkillsData(10)
Regards Robert
-
robdehn
oops you are right it is a dynamic array
i have tried to redim the array but still come
up with that error???
any ideas on that one?????
-
robdehn's reply
When do you get the error?
I can both read and write to the redimed array!
-
here it is i redimed it but the error occured at the same place?????
Code:
Function popEditSkills(theForm As Form) As Integer
'****************************************************************
' Populate the skills part of the form with the valid skills
' from the database
Dim i As Integer
Dim j As Integer
Dim theindex As Integer
Dim tempDyna As Recordset
Dim noData As Boolean
ReDim outSkillsData(10)
noData = False
On Local Error Resume Next
If UBound(outSkillsData, 2) = 0 Then noData = True
On Local Error GoTo 0
If noData Then
'if outSkillsData is empty then this routine will fill the array from the database
'and pop the outline at the same time
With theForm.outSkills
.Clear
.AddItem "Technical"
-
Try this and see if it works:
Dim outSkillsData() As String