Run-time error 6015 (1 Viewer)

mrfixit1170

New member
Local time
Today, 03:14
Joined
Aug 18, 2010
Messages
2
Hello all,
I'm a getting this error when I try to add items to one listbox to another list box. The narrative for the error says that "Can't add this item. The index is too large."


I am running win 7 and this application is a ms Access 2007 adp. A user selects a product from the Stock list listbox (lstNoBarcode) by doubleclicking the item in the list. It fires a piece of code: (see zip for pics)
Code:
[FONT=Calibri][SIZE=3]Private Sub lstNoBarcode_DblClick(Cancel As Integer)[/SIZE][/FONT]
[SIZE=3][FONT=Calibri]   AddSelectedProduct[/FONT][/SIZE]
[FONT=Calibri][SIZE=3]End Sub[/SIZE][/FONT]

Code:
[FONT=Calibri][SIZE=3]Private Sub AddSelectedProduct()[/SIZE][/FONT]
[SIZE=3][FONT=Calibri]   If Not IsNull(Me.lstNoBarcode.Value) Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sp.Load Me.lstNoBarcode.Value[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       spb.LoadCK sp.SP_ID, CurrentUser.B_ID[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       If spb.SPB_MinLocation = 0 Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           ErrorMessage "This product is not assigned to a stock location."[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           Exit Sub[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       Else[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           sl.Load spb.SPB_MinLocation[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           AddProduct[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           product = ""[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       End If[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   End If[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   Me.txtScan.SetFocus[/FONT][/SIZE]
[FONT=Calibri][SIZE=3]End Sub[/SIZE][/FONT]

Code:
[FONT=Calibri][SIZE=3]Private Sub AddProduct()[/SIZE][/FONT]
[SIZE=3][FONT=Calibri]   Dim i As Integer[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   For i = 1 To Me.lstProducts.ListCount - 1[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       If Me.lstProducts.Column(0, i) = sp.SP_ID Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           ReplaceRow i, enProduct[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           lstProducts.Value = sp.SP_ID[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           lstProducts_Click[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]           Exit Sub[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       End If[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   Next i[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   'Test[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   Me.lstProducts.AddItem _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sp.SP_ID & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sl.SL_ID & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       1 & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       Now() & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sp.SP_MDANo & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sp.SP_Name & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       sp.SP_DisplayUI & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       1 & ";" & _[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       spb.SPB_OnHand[/FONT][/SIZE]
 
[SIZE=3][FONT=Calibri]   lstProducts.Value = sp.SP_ID[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   lstProducts_Click[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   If Me.cmdSubmit.Enabled = False Then[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       Me.cmdSubmit.Enabled = True[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]       Me.cmdClearAll.Enabled = True[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   End If[/FONT][/SIZE]
[SIZE=3][FONT=Calibri]   Me.txtScan.SetFocus[/FONT][/SIZE]
[FONT=Calibri][SIZE=3]End Sub[/SIZE][/FONT]

If you need to increase the amount of an item then just double click the item in the “Stock List” listbox and the amount increases in the adjacent quantity column. (see zip for pics)

Where the problem resides is when there is only 1 item on the list and the item has a zero quantity in the inventory, (I know it is a zero quantity because I can chk in the database, the user would get a warning telling the user an item is at a zero balance when he/she would click the “Submit” button.) and the user increases the amount for the same item. (see zip for pics)
I hope my explaination makes sense...I posted a zip with screenshots. I hope they will clarify the question I am asking.
 

Attachments

  • helpdeskrequest.zip
    554.1 KB · Views: 111

mrfixit1170

New member
Local time
Today, 03:14
Joined
Aug 18, 2010
Messages
2
Thanks...I did find the reference to the post you suggested, but couldn't really get it to work in my application. I just don't have the coding expertise yet to modify my code to the suggested technique using the Sub ListQueries().....Thank you for your insight....
 

Users who are viewing this thread

Top Bottom