Array issue - out of range
Forums
Hi
I am having some issues with array declaration - the values for 4 elements of my array come from droplistbox in a dialog box however the code stops at first line of my array declaration:
UserSelection(1) = DateFieldArray(UserBox.DropListBox1)) and generates the error: "subscript aout of range.
I cannot figure out the issue since i declared my UserSelection array as 4 elements array.
Code attached
Thank you Brian.
Thank you Brian.
It is puzzling me because i thought that could be an issue since i started declaring my array from 1 rather than 0 however i did run it with +1 option after DropListbox(number) and it didnt work however i think I also might have each Redim Preserve line for each DropListbox set with (j-1) i.e: ReDim Preserve SecDBDateFieldArray(j-1) and that might have casued some issue too.
It works now so many thanks and thank you for having me on your forum.
It is because you have use
It is because you have use the Option Base 1 for your arrays, so that means your array cannot contain a 0. For each of your UserBox.DropListBox1 if you select the first item on the list that item will return 0, it is just the way the DropListBox is built. So you have to make sure that since your arrays all start at 1 that you always add 1 for each UserBox.DropListBox that you access. So all your arrays need to have the one added to it such as:
UserSelection(1) = DateFieldArray(UserBox.DropListBox1+1)
Your errors where for the selections where you weren't add 1 to the UserBox.DropListBox1.
Hope that helps out and welcome to the site.
Brian