Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Gallaxy  
#1 Posted : Saturday, January 28, 2017 10:00:10 AM(UTC)
Gallaxy

Rank: Newbie

Groups: Registered
Joined: 1/28/2017(UTC)
Posts: 2

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

Code:

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  
#2 Posted : Monday, January 30, 2017 4:00:14 PM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,111

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
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  
#3 Posted : Monday, January 30, 2017 4:24:08 PM(UTC)
Gallaxy

Rank: Newbie

Groups: Registered
Joined: 1/28/2017(UTC)
Posts: 2

Hello Igor,

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


But how does this work with "RowIndex"?

Code:
Property Get RowIndex( _
   sKey As String _
) As Long
Igor/10Tec  
#4 Posted : Tuesday, January 31, 2017 8:55:58 AM(UTC)
Igor/10Tec

Rank: Administration

Groups: Administrators, Forum Moderator
Joined: 1/17/2011(UTC)
Posts: 1,111

Thanks: 15 times
Was thanked: 141 time(s) in 141 post(s)
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:

Code:
iGrid1.SetCurCell iGrid1.RowIndex("L003"), 1
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.