Gallaxy
2017-01-28T10:00:10Z
Who can help me with the use of RowIndex?
I need the selection of the line for the evaluation in other areas of the application. The provision of the ID must work very quickly.

Regards
Gallaxy


Option Compare Database
Dim objGrid As iGrid


Private Sub Form_Load()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim SQL1 As String

SQL1 = "SELECT EmpID, Typ, Kunde, Ort, KundenNr FROM a_kunde_4;"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL1, dbOpenDynaset, dbConsistent)

Set objGrid = iGrid7.Object

objGrid.AddCol sHeader:="EmpID", sKey:="EmpID", bVisible:=False
objGrid.AddCol sHeader:="Typ", sKey:="Typ"
objGrid.AddCol sHeader:="Kunde", sKey:="Kunde"
objGrid.AddCol sHeader:="Ort", sKey:="Ort"
objGrid.AddCol sHeader:="KundenNr", sKey:="KundenNr"
objGrid.FillFromRS rs, igFillRSColsIfEmptyAndRows, "EmpID"

'Test
Debug.Print objGrid.RowIndex("EmpID")
End Sub


Private Sub iGrid7_ClickNoDblClick(ByVal lRowIfAny As Long, ByVal lColIfAny As Long)

'Test RowKey etc. (to slow!!!)
Debug.Print objGrid.CellValue(lRowIfAny, 1)
Debug.Print objGrid.RowKey(lRowIfAny)
Debug.Print objGrid.RowVisibleIndex(lRowIfAny)


'Test Row Index
Debug.Print objGrid.RowIndex("EmpID")
End Sub
Igor/10Tec
2017-01-30T16:00:14Z
Do you need to retrieve the EmpID for the clicked row? You have this value in the hidden EmpID column, and you can get it in the ClickNoDblClick event using the expression objGrid.CellValue(lRowIfAny, "EmpID").
Gallaxy
2017-01-30T16:24:08Z
Hello Igor,

this is the same as my CodeSnip:
Debug.Print objGrid.CellValue(lRowIfAny, 1)


But how does this work with "RowIndex"?

Property Get RowIndex( _
   sKey As String _
) As Long
Igor/10Tec
2017-01-31T08:55:58Z
Perhaps, I do not understand your question. You asked how to retrieve the EmpID for the currently clicked row, and we answered.

If we talk about the RowIndex function, it is used to find the numeric index of the row with the specified string key. For instance, if you need to select the row with the "L003" row key in row mode, the code will look like this:

iGrid1.SetCurCell iGrid1.RowIndex("L003"), 1