J
James
I needed to use a datasource for a report so I found this microsoft
article and based my code off of theirs:
http://support.microsoft.com/default.aspx?scid=kb;en-us;132881
When my code gets to step 12, it errors out at rs.bookmark = pagestart
"Run time error 3001: Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another"
It's getting pagestart and rs.bookmark from Detail_Format and erroring
out in Detail_Print.... any ideas?? Thanks.
Here's my code, sorry it's a lot:
Option Compare Database
Option Explicit
'Report data source
Private reportData As DataSource
Private fm As New FormManager
Dim rs As Recordset
Dim PageStart As Integer
Dim m_sourceData As String
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim i As Integer
'Prints key so users can understand what all the fields are
Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 0
Me.Print "Off.ID"; ' or [Company Name] in Microsoft
' Access 2.0
'Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 450
Me.Print "Offering Name";
Me.CurrentX = 1440 * 3.5
Me.Print "Offering Category";
Me.CurrentX = 1440 * 4.75
Me.Print "Offering SubCategory";
Me.CurrentX = 1440 * 6.25
Me.Print "Offering Group";
Me.CurrentX = 1440 * 10.5
Me.Print "Position Indicator"
'Line 2
Me.CurrentX = 470
'Me.CurrentY = (i + 0.2) * (1440 * (2 / 3))
Me.Print "Launch Point"
'Line 3
'Me.CurrentY = (i + 0.4) * (1440 * (2 / 3))
Me.CurrentX = 460
Me.Print "Application Type";
Me.CurrentX = 1440 * 1.5
Me.Print "Dual Facing";
Me.CurrentX = 1440 * 3.5
Me.Print "Verify";
Me.CurrentX = 1440 * 4.75
Me.Print "AppID";
Me.CurrentX = 1440 * 7
Me.Print "Context";
Me.CurrentX = 1440 * 8
Me.Print "Tool Tip";
Me.CurrentX = 1440 * 9
Me.Print "Hot Key";
Me.CurrentX = 1440 * 10
Me.Print "Criteria"
'Line 4
Me.CurrentX = 460
Me.Print "Transaction Context Info"
'Line 5
Me.CurrentX = 460
Me.Print "Version";
Me.CurrentX = 1440 * 1.5
Me.Print "Last Modified";
Me.CurrentX = 1440 * 2.25
Me.Print "Modified By";
Me.CurrentX = 1440 * 3.5
Me.Print "Release Name"
End Sub
Private Sub Report_Open(Cancel As Integer)
Set rs = Forms!DisplayOfferings.reportData
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
' 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
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' 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 < 9
i = i + 1
rs.MoveNext
Loop
End If
End If
Me.NextRecord = rs.EOF
Me.MoveLayout = Not rs.EOF
End Sub
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
'Prints report
' 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 < 9
Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 0
Me.Print rs![OfferingID]; ' or [Company Name] in Microsoft
' Access 2.0
Me.CurrentX = 450
Me.Print rs![OfferingName];
Me.CurrentX = 1440 * 3.5
Me.Print rs![OfferingCategory];
Me.CurrentX = 1440 * 4.75
Me.Print rs![OfferingSubCategory];
Me.CurrentX = 1440 * 6.25
Me.Print rs![OfferingGroup];
Me.CurrentX = 1440 * 10.5
Me.Print rs![PositionIndicator]
'Line 2
Me.CurrentX = 470
'Me.CurrentY = (i + 0.2) * (1440 * (2 / 3))
Me.Print rs![LaunchPoint]
'Line 3
'Me.CurrentY = (i + 0.4) * (1440 * (2 / 3))
Me.CurrentX = 460
Me.Print rs![ApplicationType];
Me.CurrentX = 1440 * 1.5
Me.Print rs![DualFacing];
Me.CurrentX = 1440 * 3.5
Me.Print rs![Verify];
Me.CurrentX = 1440 * 4.75
Me.Print rs![AppID];
Me.CurrentX = 1440 * 7
Me.Print rs![Context];
Me.CurrentX = 1440 * 8
Me.Print rs![ToolTip];
Me.CurrentX = 1440 * 9
Me.Print rs![HotKey];
Me.CurrentX = 1440 * 10
Me.Print rs![Criteria]
'Line 4
Me.CurrentX = 460
Me.Print rs![TransactionContextInfo]
'Line 5
Me.CurrentX = 460
Me.Print rs![Version];
Me.CurrentX = 1440 * 1.5
Me.Print rs![LastModified];
Me.CurrentX = 1440 * 2.25
Me.Print rs![ModifiedBy];
Me.CurrentX = 1440 * 3.5
Me.Print rs![ReleaseName];
i = i + 1
If i <> 9 Then
Me.Line (0, ((i * (1440 * (65 / 100))) - 2.5))-(Me.Width, ((i *
(1440 * (65 / 100))) - 2.5))
End If
rs.MoveNext
Loop
End Sub
Private Sub Report_Close()
' To close the recordset when the report has been printed.
rs.Close
End Sub
article and based my code off of theirs:
http://support.microsoft.com/default.aspx?scid=kb;en-us;132881
When my code gets to step 12, it errors out at rs.bookmark = pagestart
"Run time error 3001: Arguments are of the wrong type, are out of
acceptable range, or are in conflict with one another"
It's getting pagestart and rs.bookmark from Detail_Format and erroring
out in Detail_Print.... any ideas?? Thanks.
Here's my code, sorry it's a lot:
Option Compare Database
Option Explicit
'Report data source
Private reportData As DataSource
Private fm As New FormManager
Dim rs As Recordset
Dim PageStart As Integer
Dim m_sourceData As String
Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As
Integer)
Dim i As Integer
'Prints key so users can understand what all the fields are
Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 0
Me.Print "Off.ID"; ' or [Company Name] in Microsoft
' Access 2.0
'Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 450
Me.Print "Offering Name";
Me.CurrentX = 1440 * 3.5
Me.Print "Offering Category";
Me.CurrentX = 1440 * 4.75
Me.Print "Offering SubCategory";
Me.CurrentX = 1440 * 6.25
Me.Print "Offering Group";
Me.CurrentX = 1440 * 10.5
Me.Print "Position Indicator"
'Line 2
Me.CurrentX = 470
'Me.CurrentY = (i + 0.2) * (1440 * (2 / 3))
Me.Print "Launch Point"
'Line 3
'Me.CurrentY = (i + 0.4) * (1440 * (2 / 3))
Me.CurrentX = 460
Me.Print "Application Type";
Me.CurrentX = 1440 * 1.5
Me.Print "Dual Facing";
Me.CurrentX = 1440 * 3.5
Me.Print "Verify";
Me.CurrentX = 1440 * 4.75
Me.Print "AppID";
Me.CurrentX = 1440 * 7
Me.Print "Context";
Me.CurrentX = 1440 * 8
Me.Print "Tool Tip";
Me.CurrentX = 1440 * 9
Me.Print "Hot Key";
Me.CurrentX = 1440 * 10
Me.Print "Criteria"
'Line 4
Me.CurrentX = 460
Me.Print "Transaction Context Info"
'Line 5
Me.CurrentX = 460
Me.Print "Version";
Me.CurrentX = 1440 * 1.5
Me.Print "Last Modified";
Me.CurrentX = 1440 * 2.25
Me.Print "Modified By";
Me.CurrentX = 1440 * 3.5
Me.Print "Release Name"
End Sub
Private Sub Report_Open(Cancel As Integer)
Set rs = Forms!DisplayOfferings.reportData
End Sub
Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As
Integer)
' 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
End Sub
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
' 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 < 9
i = i + 1
rs.MoveNext
Loop
End If
End If
Me.NextRecord = rs.EOF
Me.MoveLayout = Not rs.EOF
End Sub
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
'Prints report
' 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 < 9
Me.CurrentY = i * (1440 * (65 / 100))
Me.CurrentX = 0
Me.Print rs![OfferingID]; ' or [Company Name] in Microsoft
' Access 2.0
Me.CurrentX = 450
Me.Print rs![OfferingName];
Me.CurrentX = 1440 * 3.5
Me.Print rs![OfferingCategory];
Me.CurrentX = 1440 * 4.75
Me.Print rs![OfferingSubCategory];
Me.CurrentX = 1440 * 6.25
Me.Print rs![OfferingGroup];
Me.CurrentX = 1440 * 10.5
Me.Print rs![PositionIndicator]
'Line 2
Me.CurrentX = 470
'Me.CurrentY = (i + 0.2) * (1440 * (2 / 3))
Me.Print rs![LaunchPoint]
'Line 3
'Me.CurrentY = (i + 0.4) * (1440 * (2 / 3))
Me.CurrentX = 460
Me.Print rs![ApplicationType];
Me.CurrentX = 1440 * 1.5
Me.Print rs![DualFacing];
Me.CurrentX = 1440 * 3.5
Me.Print rs![Verify];
Me.CurrentX = 1440 * 4.75
Me.Print rs![AppID];
Me.CurrentX = 1440 * 7
Me.Print rs![Context];
Me.CurrentX = 1440 * 8
Me.Print rs![ToolTip];
Me.CurrentX = 1440 * 9
Me.Print rs![HotKey];
Me.CurrentX = 1440 * 10
Me.Print rs![Criteria]
'Line 4
Me.CurrentX = 460
Me.Print rs![TransactionContextInfo]
'Line 5
Me.CurrentX = 460
Me.Print rs![Version];
Me.CurrentX = 1440 * 1.5
Me.Print rs![LastModified];
Me.CurrentX = 1440 * 2.25
Me.Print rs![ModifiedBy];
Me.CurrentX = 1440 * 3.5
Me.Print rs![ReleaseName];
i = i + 1
If i <> 9 Then
Me.Line (0, ((i * (1440 * (65 / 100))) - 2.5))-(Me.Width, ((i *
(1440 * (65 / 100))) - 2.5))
End If
rs.MoveNext
Loop
End Sub
Private Sub Report_Close()
' To close the recordset when the report has been printed.
rs.Close
End Sub