Option Explicit
Private m_CombinedNames As String
‘Display the first 10 records.
Private Sub cmdList_Click()
‘ Reset m_CombinedNames
‘ to select the first record.
m_CombinedNames = “,”
‘ Get the next 10 records.
cmdNext.Enabled = True
cmdNext_Click
End Sub
‘ Display the next 10 records.
Private Sub cmdNext_Click()
Dim DB_Name As String
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim txt As String
Dim i As Integer
‘ Get the database name.
DB_Name = App.Path
If Right$(DB_Name, 1) <> “” Then DB_Name = DB_Name & “”
DB_Name = DB_Name & “Employee.mdb”
‘ Open a connection.
Set Conn = New ADODB.Connection
Conn.ConnectionString = “Provider=Microsoft.Jet.OLEDB.4.0;” & “Data Source=” & DB_Name & “;” & _
“Persist Security Info=False”
Conn.Open
‘ Get the next 10 records.
Set RS = Conn.Execute(“SELECT TOP 10 * FROM Employees “ & “WHERE LastName + ‘,’ + _
FirstName > “ & “‘” & m_CombinedNames & “‘ ORDER BY LastName, “ & “FirstName”)
‘ Display the records.
Do until RS.EOF
i = i + 1
txt = txt & vbCrLf & Format$(RS!EmployeeId, “@@@”) & ” “ & _
Format$(RS!LastName, “!@@@@@@@@@@@@@”) & Format$(RS!FirstName, “!@@@@@@@@@@@@@”)
m_CombinedNames = RS!LastName & “,” & RS!FirstName
RS.MoveNext
Loop
‘ See if we ran out of records.
If i < 10 Then
txt = txt & vbCrLf & “<END>”
cmdNext.Enabled = False
End If
‘ Display the data.
If Len(txt) > 0 Then txt = Mid$(txt, 3)
txtEmployees.Text = txt
End Sub