by N. Pandu Ranga Rao (3 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 10th December 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
To Display pagewise values from Records in a form in Visual Basic.
API Declarations
Dim Con As ADODB.Connection
Dim Rs1 As ADODB.Recordset
Dim Idex As Integer
Private Sub Form_Load()
Set Con = New ADODB.Connection
Set Rs1 = New ADODB.Recordset
Set Rs2 = New ADODB.Recordset
Con.Open "Data Source=Hotel;", "Hotel", "Hotel"
Rs1.CursorLocation = adUseClient
Rs1.Open "Select * from Rooms", Con, adOpenDynamic, adLockBatchOptimistic, adCmdText
End Sub
'To display a set of records for the first time.
Public Sub PrintFirstPage()
Dim cmdi, i As Integer
If Rs1.EOF Then Exit Sub
Rs1.Sort = "FieldName"
Rs1.MoveFirst
Rs1.PageSize = 20 'Records per page.
VarPageCnt = Rs1.PageCount
Idex = 1
Rs1.AbsolutePage = Idex
For i = 0 To 20
Command8(i).Caption = ""
Next i
cmdi = 0
For i = 1 To 21
Command8(cmdi).Caption = Rs1("FieldName").Value
cmdi = cmdi + 1
Rs1.MoveNext
If Rs1.EOF Then Exit For
Next i
End Sub
'Prints next Page.
Public Sub PrintNextPage()
Dim cmdi, i As Integer
If Rs1.EOF Then Exit Sub
Idex = Idex + 1
Rs1.AbsolutePage = Idex
For i = 0 To 20
Command8(i).Caption = ""
Next i
cmdi = 0
For i = 1 To 21
Command8(cmdi).Caption = Rs1("FieldName").Value
cmdi = cmdi + 1
Rs1.MoveNext
If Rs1.EOF Then Exit For
Next i
If Idex = Rs1.PageCount Then
Command9.Enabled = False
End If
Command11.Enabled = True
End Sub
'Prints Previous Page.
Public Sub PrintPreviousPage()
Dim cmdi, i As Integer
Idex = Idex - 1
Rs1.AbsolutePage = Idex
For i = 0 To 20
Command8(i).Caption = ""
Next i
cmdi = 0
For i = 1 To 21
Command8(cmdi).Caption = Rs1("FieldName").Value
cmdi = cmdi + 1
Rs1.MoveNext
Next i
If Idex = 1 Then
Command11.Enabled = False
End If
Command9.Enabled = True
End Sub
No comments have been posted about To Display pagewise values from Records in a form in Visual Basic.. Why not be the first to post a comment about To Display pagewise values from Records in a form in Visual Basic..