Home > Software engineering >  Shows the position of the selected records in the datagrid on label,,
Shows the position of the selected records in the datagrid on label,,

Time:09-28

Know you have a absoluteposition but don't know how to do,

CodePudding user response:

Key to set CursorLocation=adUseClient AbsolutePosition is the line number, starting from 1
The
MSDN help: 6.0
AbsolutePosition sample and CursorLocation attribute
This example to explain how the AbsolutePosition attribute to enumerate all you record the circulation process of tracking, it sets the cursor to the client cursor, using CursorLocation activation AbsolutePosition attribute,

 Public Sub AbsolutePositionX () 

Dim rstEmployees As ADODB. You
Dim strCnn As String
Dim strMessage As String

'using client-side cursor table for employee opens a recordset,
StrCnn="Provider=sqloledb;" & _
"Data Source=the SRV; Initial Catalog=pubs; User Id=sa; Password=; "
The Set rstEmployees=New ADODB. You
'using client-side cursor activation AbsolutePosition properties,
RstEmployees. CursorLocation=adUseClient
RstEmployees. Open "employee," strCnn,,, adCmdTable

'enumeration recordset,
The Do While Not rstEmployees. EOF
'display the current record information,
StrMessage="Employee:" & amp; RstEmployees! LName & amp; VbCr & amp; _
"(record" & amp; RstEmployees. AbsolutePosition & amp; _
"Of" & amp; RstEmployees. RecordCount & amp;
")"If MsgBox (strMessage vbOKCancel)=vbCancel _
Then the Exit Do
RstEmployees. MoveNext
Loop

RstEmployees. Close

End Sub

CodePudding user response:

reference 1st floor Tiger_Zhao response:
key to set CursorLocation=adUseClient AbsolutePosition is the line number, starting from 1
[Quote=MSDN help: 6.0] AbsolutePosition and sample CursorLocation attribute
This example to explain how the AbsolutePosition attribute to enumerate all you record the circulation process of tracking, it sets the cursor to the client cursor, using CursorLocation activation AbsolutePosition attribute,

 Public Sub AbsolutePositionX () 

Dim rstEmployees As ADODB. You
Dim strCnn As String
Dim strMessage As String

'using client-side cursor table for employee opens a recordset,
StrCnn="Provider=sqloledb;" & _
"Data Source=the SRV; Initial Catalog=pubs; User Id=sa; Password=; "
The Set rstEmployees=New ADODB. You
'using client-side cursor activation AbsolutePosition properties,
RstEmployees. CursorLocation=adUseClient
RstEmployees. Open "employee," strCnn,,, adCmdTable

'enumeration recordset,
The Do While Not rstEmployees. EOF
'display the current record information,
StrMessage="Employee:" & amp; RstEmployees! LName & amp; VbCr & amp; _
"(record" & amp; RstEmployees. AbsolutePosition & amp; _
"Of" & amp; RstEmployees. RecordCount & amp;
")"If MsgBox (strMessage vbOKCancel)=vbCancel _
Then the Exit Do
RstEmployees. MoveNext
Loop

RstEmployees. Close

End Sub


1. RstEmployees! LName this variable represent?
2. The operating interface is moving on the datagrid record, the above code simply connect to the database, can have a detail,

CodePudding user response:

And you only CursorLocation and AbsolutePosition,