View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Changed variable value

I would recommend that you set up a Watch on that variable. In VBA, go to
the Debug menu and choose Add Watch. In that dialog, enter ChoiceIndex as
the Expression, select All Procedures in the Procedure drop down, select All
Modules in the Module drop down, and choose Break When Value Changes in the
Watch Type option box. This will cause VBA to pause on the line(s) of code
that change the value of ChoiceIndex.

Also, you should put "Option Explicit" as the very first line in the module
(above and outside of any procedures) to ensure that the variable is
declared and that you don't have a misspelled variable name.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Karen53" wrote in message
...
Hi,

I have been unable to locate what is happening and am hoping someone can
provide some insight.

I have a variable, 'ChoiceIndex', where I save what index the user chose
in
a listbox so I can reset it back to their choice when resetting the
listbox.
My debug.prints all indicate the correct information, Column 'U' and row
'72', up until the reset then all of a sudden ChoiceIndex is '68' instead
of
'72'.

I performed a Find for 'ChoiceIndex' on the entire project and this
variable
simply does not exist anywhere else for it to change. It only exists in
this
procedure.

The error message is #380.
Could not set the ListIndex property. Invalid property value.

Does anyone have any ideas as to what is happening?

Here's the procedu

Sub UpdateLineItem()

'save the changes to the Line Item lists
'command button from frmPoolList, btn = cmdUpdate

Debug.Print "Starting UpdateLineItem " & Application.ScreenUpdating

Dim ItemFRow As Long 'first row of Line Items - Tablespg
Dim ItemCol As String 'column of the Line Item - Tablespg
Line
Items ranges
Dim AmountCol As String 'column of the Line Item amount -
Tablespg Line Items ranges
Dim ItemRange As String 'range to hold the specific name of
range being used
Dim PoolCol As String 'column for pool assigned to Line
Item -
Tablespg Line Items ranges
Dim PoolTypeCol As String 'PoolType column in PoolTypes ranges
Dim LineItemFCell As String 'first cell of the Exterior Line
Items -
LineItemspg
Dim IntLineItemFCell As String 'first cell of the Interior Line
Items -
LineItemspg
Dim IntLineItemFRow As Long 'first row of the Interior Line Items -
LineItemspg
Dim LineItemLCol As String 'Last column of Line Items -
LineItemspg
Dim Good As Boolean 'Validate Data
Dim ChoiceIndex As Long 'save the user's choice

Application.ScreenUpdating = False

ChoiceIndex = frmPoolList.lboPoolList.ListIndex

Call ValidateItemData(Good)

If Good = False Then
GoTo NoGood
Else
'determine which Item List to save
If frmPoolList.lboPoolList.RowSource =
Worksheets(Replace(Tablespg.Name, "", "''")).Range _

("CAMLineItemsExterior").Address(external:=True ) Then
Call CAMLineItemExteriorLocations(ItemFRow, ItemCol, AmountCol,
PoolCol, ItemRange, _
PoolTypeCol,
LineItemFCell, LineItemLCol)
Debug.Print "Update Ext LI ItemCol " & ItemCol


Debug.Print "UpdateLineItem Ext call SaveLineItems " &
Application.ScreenUpdating
Call SaveLineItems(ItemCol, AmountCol, PoolCol, ItemRange,
PoolTypeCol, LineItemFCell, _
IntLineItemFCell,
LineItemLCol, IntLineItemFRow)

Debug.Print "UpdateLineItem Ext call UpdateLIneItemsPage " &
Application.ScreenUpdating
Call UpdateLineItemsPage(ItemFRow, ItemCol, AmountCol, PoolCol,
ItemRange, PoolTypeCol, _
LineItemFCell, IntLineItemFCell,
LineItemLCol, IntLineItemFRow)
'reset the rowsource for updates
With frmPoolList.lboPoolList
.RowSource = ""
.RowSource = Worksheets(Replace(Tablespg.Name, "",
"''")).Range _

(ItemRange).Address(external:=True)
End With

ElseIf frmPoolList.lboPoolList.RowSource =
Worksheets(Replace(Tablespg.Name, "", "''")).Range _

("CAMLineItemsInterior").Address(external:=True ) Then
Call CAMLIneItemInteriorLocations(ItemFRow, ItemCol, AmountCol,
PoolCol, ItemRange, _
PoolTypeCol, IntLineItemFCell, LineItemLCol,
IntLineItemFRow, LineItemFCell)
Debug.Print "Update Int LI ItemCol " & ItemCol


Debug.Print "UpdateLineItem Int call SaveLineItems " &
Application.ScreenUpdating
Call SaveLineItems(ItemCol, AmountCol, PoolCol, ItemRange,
PoolTypeCol, LineItemFCell, _
IntLineItemFCell,
LineItemLCol, IntLineItemFRow)

Debug.Print "UpdateLineItem Int call UpdateLIneItemsPage " &
Application.ScreenUpdating
Call UpdateLineItemsPage(ItemFRow, ItemCol, AmountCol, PoolCol,
ItemRange, PoolTypeCol, _
LineItemFCell, IntLineItemFCell,
LineItemLCol, IntLineItemFRow)
'reset the rowsource for updates
With frmPoolList.lboPoolList
.RowSource = ""
.RowSource = Worksheets(Replace(Tablespg.Name, "",
"''")).Range _

(ItemRange).Address(external:=True)
End With
End If

If frmPoolList.lboPoolList.RowSource =
Worksheets(Replace(Tablespg.Name, "", "''")).Range _

("TaxLineItems").Address(external:=True) Then
Call TaxLineItemLocations(ItemFRow, ItemCol, AmountCol,
PoolCol,
ItemRange, _
PoolTypeCol, LineItemFCell,
LineItemLCol)

Debug.Print "UpdateLineItem Tax call SaveLineItems " &
Application.ScreenUpdating
Call SaveLineItems(ItemCol, AmountCol, PoolCol, ItemRange,
PoolTypeCol, LineItemFCell, _
IntLineItemFCell,
LineItemLCol, IntLineItemFRow)
Debug.Print "UpdateLineItem Tax call UpdateLIneItemsPage " &
Application.ScreenUpdating
Call UpdateLineItemsPage(ItemFRow, ItemCol, AmountCol, PoolCol,
ItemRange, PoolTypeCol, _
LineItemFCell, IntLineItemFCell,
LineItemLCol, IntLineItemFRow)
'reset the rowsource for updates
With frmPoolList.lboPoolList
.RowSource = ""
.RowSource = Worksheets(Replace(Tablespg.Name, "",
"''")).Range _

(ItemRange).Address(external:=True)
End With
End If
End If

NoGood:

'Reset
'clear the textbox
frmPoolList.txtNewPoolType.Value = ""
frmPoolList.txtLineItemAmount.Value = ""

'clear the Pool list box
frmPoolList.lboLineItemPool.ListIndex = -1

'reset the PoolList list box to user's choice
Debug.Print "ChoiceIndex = " & ChoiceIndex
frmPoolList.lboPoolList.ListIndex = ChoiceIndex
(((This is where the value changes & error
occurs)))

Application.ScreenUpdating = True

Debug.Print "UpdateLineItem Close " & Application.ScreenUpdating

End Sub

--
Thanks for your help.
Karen53