Posting the code that causes the error message will usually get a better
response.
- Show quoted text -
Here is the code:
'Background:
'A list box shows the list of existing products.
'The list box is called lstExistingProducts.
'The ListFillRange of the lstExistingProducts is called ListOfProducts
'DoDeleteProduct routine deletes the Product in the database.
'The routine RefreshCurrentProductList refreshes the ListOfProducts
range from database
'ListExistingProducts.ListFillRange is again set so that a refresh of
the ListBox takes place
'This line causes the problem. "Could not set the ListCursor property.
Not enough storage is available to complete this operation"
'After getting this error, I would get the following error:
'Microsoft Office Excel cannot save this workbook because the control
named lstExistingProducts does not support saving. To save the
workbook, delete this control, and then try the save again."
'Note that the problem happened only if the last item in the
lstExistingProducts had been clicked on for deletion.
'I was able to resolve the problem by first unselecting the selected
item by adding the code
'lstExistingProducts.ListIndex = -1 between
'RefreshCurrentProductList and
'lstExistingProducts.ListFillRange = "ListOfProducts"
Private Sub butDeleteProduct_Click()
Dim sExistingProduct$
sExistingProduct = lstExistingProducts.Text
If sExistingProduct <> "" Then
If MsgBox("Do you want to delete " & sExistingProduct & "?",
vbYesNo) = vbYes Then
DoDeleteProduct sExistingProduct
RefreshCurrentProductsList
lstExistingProducts.ListFillRange = "ListOfProducts"
End If
Else
MsgBox "Please note that you must first select a product and
then click on the 'Delete Product' button."
End If
End Sub
As you will see from the background the problem was solved in a
roundabout way by me. If you have another solution, please let me
know.