PercentPosition Property Example

This example illustrates use of the PercentPosition property. In this example a list of publishers is generated and when one of these is chosen, a list of associated titles is displayed in a DataGrid control. When the scroll bar associated with the grid is manipulated, the relative location of the selected row is determined by examining the PercentPosition property and displayed. See the AbsolutePosition property example for further details on this example.

Dim rs As rdoResultset

Private Sub Form_Load()
Dim Li As Integer
'
'   Fill Sections list combo box.
'
Set en = rdoEnvironments(0)
Set cn = en.OpenConnection(dsName:="", _
    Prompt:=rdDriverNoPrompt, _
    Connect:="uid=;pwd=;driver={SQL Server};" _
        & "server=BETAV486;database=pubs;")

MsRdc1.Connect = cn.Connect

Set rs = cn.OpenResultset _
    ("Select distinct Pub_Name, Pub_ID from Publishers", rdOpenStatic, rdConcurReadOnly)
Do Until rs.EOF
    If rs(0) = Null Then
    Else
        PubList.AddItem " " & rs!Pub_ID & ":" & rs!Pub_Name
    End If
    rs.MoveNext
Loop
PubList.ListIndex = 1
rs.Close

Publist_Click


End Sub

Private Sub MoveCRow_Change()
MoveCRow_Scroll
End Sub

Private Sub MoveCRow_Scroll()
PercentPoint = MoveCRow.Value & "%"
MsRdc1.Resultset.PercentPosition = MoveCRow.Value
End Sub

Private Sub Publist_Click()
SetSQL
If MsRdc1.Resultset.EOF Then
    MoveCRow.Enabled = False
Else
    MoveCRow.Enabled = True
    MsRdc1.Resultset.MoveFirst
End If
End Sub

Sub SetSQL()
Dim PubWanted As String
PubWanted = Trim(Left(PubList, InStr(PubList, ":") - 1))
Screen.MousePointer = vbHourglass

MsRdc1.SQL = "select * from Titles" _
    & " where Pub_ID = '" _
    & PubWanted & "'" _
    & " order by Title"
MsRdc1.Refresh
Screen.MousePointer = vbDefault
End Sub