Article ID: 132881
Article Last Modified on 10/11/2006
Report: RecordSet Report
----------------------------------
RecordSource: <Leave blank>
Caption: Report Based on Recordset
Width: 6.5 inches
Option Explicit Dim db As Database, rs As Recordset, PageStart As String
' To create a Recordset object based on the Customers table.
Set db = DBEngine.Workspaces(0).Databases(0)
Set rs = db.OpenRecordset("Customers")
' To close the recordset when the report has been printed. rs.Close db.Close
' To reset the pointer to the first record in the recordset. rs.MoveFirst ' To set the unit of measure, font, and font size used in the ' report. Me.scalemode = 1' twips Me.fontname = "Arial" Me.FontSize = 12
' 1. Determines how many pages are needed for the report and
' sets the NextRecord and MoveLayout properties accordingly.
' 2. To save the bookmark to the first record that is printed
' on the current page when the FormatCount property is an odd
' number.
Dim i As Integer
If FormatCount Mod 2 = 1 Then
If Not rs.eof Then
PageStart = rs.Bookmark
i = 0
Do While Not rs.eof And i < 18
i = i + 1
rs.MoveNext
Loop
End If
End If
Me.nextrecord = rs.eof
Me.movelayout = Not rs.eof
' To return to the first record for that page.
Dim i As Integer
i = 0
rs.bookmark = PageStart
' To add a border around the entire page.
Me.Line (0, 0)-(Me.Width, Me.Section(0).Height), , B
' To print a page's worth of data using
' .5 inches (720 twips) per record.
Do While Not rs.eof And i < 18
Me.CurrentY = i * 720
Me.CurrentX = 0
Me.Print rs![CompanyName]; ' or [Company Name] in Microsoft
' Access 2.0
Me.CurrentX = 1440 * 3
Me.Print rs![City];
Me.CurrentX = 1440 * 5
Me.Print rs![Country];
i = i + 1
rs.MoveNext
Loop
Additional query words: dynaset unbound prevent
Keywords: kbhowto kbprogramming kbusage KB132881