Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning every 13th record

Status
Not open for further replies.

BakeMan

Programmer
Jul 24, 2002
129
US
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 = &quot;SELECT * FROM qryValidateEntriesReport WHERE ([DateEntered] > #&quot; & Forms!frmSofiVerification1.cmbDates.Column(1) & &quot;# and [DateEntered] < #&quot; & Forms!frmSofiVerification1.cmbDates.Column(2) & &quot;#) ORDER BY [ContainerNumber];&quot;
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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top