I am trying to create two reports that have the same records on them in the same order but display different fields. The problem is that I am trying to get a sampling of records over a given period of time. I created a form from which the user selects a time period (in this case a specific week). I then use this as criteria when opening the two reports. This part works fine. Now I need to filter the reports further to just give me a statistical sampling of the returned records (i.e. the square root of the number of records plus 1). I came up with a method that I thought would work for this. I created a process in each report like:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
intVRecordCount = intVRecordCount + 1
If intVRecordCount = 1 Or intVRecordCount = intVRecordMultiple Then
If intVRecordCount <> 1 Then
intVRecordMultiple = intVRecordMultiple + intVRecordMultiple1
End If
Else
Cancel = True
End If
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim DB As Database
Dim RST As Recordset
Dim strSQL As String
Dim intRecordCount As Integer
Set DB = CurrentDb()
strSQL = "SELECT * FROM qryValidateEntriesReport WHERE ([DateEntered] > #" & Forms!frmSofiVerification1.cmbDates.Column(1) & "# and [DateEntered] < #" & Forms!frmSofiVerification1.cmbDates.Column(2) & "#) ORDER BY [ContainerNumber];"
Set RST = DB.OpenRecordset(strSQL)
RST.MoveLast
intRecordCount = Int(Sqr(RST.RecordCount) + 1)
intVRecordMultiple = Int(RST.RecordCount / intRecordCount)
intVRecordMultiple1 = intVRecordMultiple
intVRecordCount = 0
RST.close
Set RST = Nothing
DB.close
Set DB = Nothing
End Sub
and declared the following in a module:
Global intVRecordCount As Integer
Global intVRecordMultiple As Integer
Global intVRecordMultiple1 As Integer
I thought this would loop through the records and only return the number I wanted but it does not return the same set each time, it does not return the same set on the two reports, and sometimes it does not return the correct number. Does anyone know how I can get two different reports based on the same data to return the same specified number of records (i.e. every 13th record).
Thank you in advance,
BAKEMAN![[pimp] [pimp] [pimp]](/data/assets/smilies/pimp.gif)
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If FormatCount = 1 Then
intVRecordCount = intVRecordCount + 1
If intVRecordCount = 1 Or intVRecordCount = intVRecordMultiple Then
If intVRecordCount <> 1 Then
intVRecordMultiple = intVRecordMultiple + intVRecordMultiple1
End If
Else
Cancel = True
End If
End If
End Sub
Private Sub Report_Open(Cancel As Integer)
Dim DB As Database
Dim RST As Recordset
Dim strSQL As String
Dim intRecordCount As Integer
Set DB = CurrentDb()
strSQL = "SELECT * FROM qryValidateEntriesReport WHERE ([DateEntered] > #" & Forms!frmSofiVerification1.cmbDates.Column(1) & "# and [DateEntered] < #" & Forms!frmSofiVerification1.cmbDates.Column(2) & "#) ORDER BY [ContainerNumber];"
Set RST = DB.OpenRecordset(strSQL)
RST.MoveLast
intRecordCount = Int(Sqr(RST.RecordCount) + 1)
intVRecordMultiple = Int(RST.RecordCount / intRecordCount)
intVRecordMultiple1 = intVRecordMultiple
intVRecordCount = 0
RST.close
Set RST = Nothing
DB.close
Set DB = Nothing
End Sub
and declared the following in a module:
Global intVRecordCount As Integer
Global intVRecordMultiple As Integer
Global intVRecordMultiple1 As Integer
I thought this would loop through the records and only return the number I wanted but it does not return the same set each time, it does not return the same set on the two reports, and sometimes it does not return the correct number. Does anyone know how I can get two different reports based on the same data to return the same specified number of records (i.e. every 13th record).
Thank you in advance,
BAKEMAN
![[pimp] [pimp] [pimp]](/data/assets/smilies/pimp.gif)