Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the selected row number from a DB Grid?

DB Grid : Row Number

How to get the selected row number from a DB Grid?

by  ameen  Posted    (Edited  )
To get the row number, when you want to double click any of the cell in the DB Grid:
Step 1:
Declare a variable in the General section:
Dim nRow as Integer
Then
Step 2:
Private Sub DBGrid1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
' To get the selected row
nRow = DBGrid1.RowContaining(Y)
End Sub

Step 3:
Private Sub DBGrid1_DblClick()
.Use Message Box to display the row number by reffering nRow
End Sub


When you want to use recordset object, put this line in the click event of first, last, previous and next button of the form.
nRow = Data1.Recordset.AbsolutePosition
Use this nRow to display the value or you can perform any other process which you want to do.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top