Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb6 run time error '381' Invalid property array index.

Posted on 2014-03-05
8
Medium Priority
?
413 Views
Last Modified: 2014-03-13
When I run the code seen below, I get the Run Time error '381' Invalid property array index. The line the debugger points to is...
.fields("fo_rackType") = Me.cboRackType.ItemData(Me.cboRackType.ListIndex)

Any ideas on how to fix this error?  Thanks in Advance,
Here's the code...

Private Sub cmdInsert_Click()
    'take the current Zone that you are on, then make the endZone the
    'endZone of the new Zone.  Have the user pick tHe beginning zone and
    'make the end of the old zone the zone prior to the beginning of the
    'new zone
    
    Dim lngZoneNumb As Long
    Dim rowZoneRow As Integer
    Dim strZoneCode As String
    Dim strZoneLoc As String
    
    If Not rsZoneConfig.EOF Then
        If Not Trim(rsZoneConfig.fields("StartZoneCode")) = Trim(rsZoneConfig.fields("endZoneCode")) Then
            
            'flag that this PickZone Configuration has changed
            Me.cboPickZoneName.ItemData(Me.cboPickZoneName.ListIndex) = 1
            
            lngZoneNumb = rsZoneConfig.fields("ZoneNumber") + 1
            rowZoneRow = Me.grdZoneConfig.Row
            strZoneCode = Trim(rsZoneConfig.fields("endZoneCode"))
            strZoneLoc = Trim(rsZoneConfig.fields("endZoneLoc"))
            
            rsZoneConfig.MoveNext
            If Not rsZoneConfig.EOF Then
                rsZoneConfig.fields("ZoneNumber") = rsZoneConfig.fields("ZoneNumber") + 1
            End If
            
            With rsZoneConfig
                .AddNew
                .fields("ZoneNumber") = lngZoneNumb
                .fields("EndZoneCode") = strZoneCode
                .fields("EndZoneLoc") = strZoneLoc
                .fields("fo_building") = Me.cboBuilding.ItemData(Me.cboBuilding.ListIndex)
                [b].fields("fo_rackType") = Me.cboRackType.ItemData(Me.cboRackType.ListIndex)
[/b]                .fields("ZoneName") = Trim(Me.cboPickZoneName.Text)
                .fields("ZoneQty") = 0
                .fields("PacksNeeded") = 0
                .fields("UnitsNeeded") = 0
            End With
            
            'reset the Zone numbers
            rsZoneConfig.MoveNext
            Dim icount As Long
            icount = lngZoneNumb + 1
            While Not rsZoneConfig.EOF
                rsZoneConfig.fields("ZoneNumber") = icount
                rsZoneConfig.MoveNext
                icount = icount + 1
            Wend
    
            rsZoneConfig.Sort = "ZoneName, fo_building, fo_rackType, ZoneNumber"
            
            Me.grdZoneConfig.Refresh
            
            Me.grdZoneConfig.Row = rowZoneRow + 1
            Call grdZoneConfig_ButtonClick(1)
        Else
            MsgBox "You can not insert a Zone Here", vbExclamation, "Pick Zone Configuration"
        End If
    End If
End Sub

Open in new window

0
Comment
Question by:tesla764
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 1500 total points
ID: 39907464
Note that ListIndex will be -1 if nothing is selected, so will not be an index into the itemdata array,
0
 

Author Comment

by:tesla764
ID: 39907552
Hi Graham,
  I'm not sure what you mean by "Code put into code box, but I now see that the line was highlighted in the text." Did you change or provide something?

Your info about the listbox being -1 is helpful.
0
 

Author Comment

by:tesla764
ID: 39907948
Thanks for the explanation, I didn't know that.  I will continue this tomorrow. Will you be available for contact?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39907988
There is no guarantee on this forum that any particular expert will be available. However as more comments are applied, the question becomes less visible to the other contributors. So, in effect, you are probably stuck with me anyway.
0
 
LVL 5

Expert Comment

by:advfinance
ID: 39908222
Not true, I'm here too! But your man Graham has got this covered.

--
Chris
0
 

Author Comment

by:tesla764
ID: 39913618
Sorry I haven't responded just yet. I will soon. I have been working on other problems that have arisen.
Thanks for you patience.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question