hai.nt > 28-04-21, 09:53 AM
ongke0711 > 28-04-21, 12:05 PM
Dim DB As DAO.Database
Dim GrpPages As DAO.Recordset
Set GrpPages = DB.OpenRecordset("Category Group Pages", dbOpenDynaset)
GrpPages.Index = "PrimaryKey"
hai.nt > 28-04-21, 02:07 PM
ongke0711 > 29-04-21, 08:36 AM
(28-04-21, 02:07 PM)hai.nt Đã viết: Mình đã sửa theo gợi ý của bạn, Code không báo lỗi nữa nhưng chạy không ra được Trang/tổng số trang. Bạn có thể sửa và chạy thử trên file mình đã đính kèm ở trên được không, cám ơn bạn
Option Compare Database
Option Explicit
Dim grpArrayPage() As Integer, grpArrayPages() As Integer
Dim grpNameCurrent As Variant, grpNamePrevious As Variant
Dim grpPage As Integer, grpPages As Integer
Public Function ReportPageOnGroup(page As Integer, Pages As Integer, varGroupValue As Variant)
Dim i As Integer
If Pages = 0 Then
ReDim Preserve grpArrayPage(page + 1)
ReDim Preserve grpArrayPages(page + 1)
grpNameCurrent = varGroupValue
If grpNameCurrent = grpNamePrevious Then
grpArrayPage(page) = grpArrayPage(page - 1) + 1
grpPages = grpArrayPage(page)
For i = page - (grpPages - 1) To page
grpArrayPages(i) = grpPages
Next
Else
grpPage = 1
grpArrayPage(page) = grpPage
grpArrayPages(page) = grpPage
End If
Else
ReportPageOnGroup = "Trang " & grpArrayPage(page) & " / " & grpArrayPages(page)
End If
grpNamePrevious = grpNameCurrent
End Function
Option Compare Database
Option Explicit
Dim clsRpt As clsPageGroupNewPage
Private Sub Report_Open(Cancel As Integer)
Set clsRpt = New clsPageGroupNewPage
End Sub
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
' Me.txtBoxPage: là textbox dùng hien thi so trang. Ví du: 'trang 1/5'
' varGroupValue: tham sô thu 3 - là 'Name' cua textbox chua ten Field dùng de Group du lieu
Me.txtBoxPage = clsRpt.ReportPageOnGroup(Me.[page], Me.[Pages], Me.txtThutubd)
End Sub
Private Sub Report_Close()
Set clsRpt = Nothing
End Sub
hai.nt > 29-04-21, 04:27 PM
hai.nt > 05-05-21, 11:06 AM
ongke0711 > 05-05-21, 11:48 AM