Use of "row" in table_selectionchanged

BjornF

Active Member
Licensed User
Longtime User
Dear All,

When I try to use the code below the first messagebox shows ok but then I get the error message in the attached file. If I choose to continue the next messagebox shows ok, and then another error message...

(I first thought there was a problem with using "row" after a filtering, hence the use of Lrow)


I don't understand why :sign0085:


B4X:
Sub TblRas_SelectionChanged (ColName, Row)
   If ColName="RasNr" OR ColName="RasNamn" Then
      If tblRas.Cell("Chosen",Row)="X" Then
         tblRas.Cell("Chosen",Row)=""
         LRow=Row
      Else
         tblRas.Cell("Chosen",Row)="X"
         LRow=Row
      End If
   End If
   
Msgbox("0:"&lrow)
   tblRas.SelectCell("Dummy",Row)
Msgbox("1:"&lrow)
   tblRas.Filter("Chosen='X'")
   If tblRas.RowCount>0 Then LblInfo.Text="Ras: " & tblRas.Cell("RasNamn",0)
   tblRas.Filter("")
Msgbox("2:"&lrow)
   tblRas.SelectCell("Dummy",LRow)
End Sub
 

klaus

Expert
Licensed User
Longtime User
The problem is that in the SelectionChanged routine you Select a new cell, which generates a new SelectionChanged event and as the new column name doesn't match the if then test there is no value assigned to lrow !

Try to put the last End If just before the End Sub statement to avoid selecting a new cell when the column doesn't match the test.

But without the whole code and without knowing what you want to do it is difficult to give other advices.

Best regards.
 

BjornF

Active Member
Licensed User
Longtime User
Aaargh, I don't know why I didn't catch it. It isn't the first time I have had problems with selection_changed. Many thanks Klaus, you have saved me :sign0188:

Björn
 
Top