L
Luc McCutcheon
Hi
I have an Access 2000 project link with a SQL Server 2000
database. In my SQL Server I have a table with some fields
who I would like to print but a different page number for
each recordset. So I had type that vba programs to do it
but when the program do the SET LastPage line I receive
that error message: Object variable or With bloc variable
not set.
Private Sub cmdPPreviewR_Test1_DblClick(Cancel As Integer)
On Error GoTo Err_cmdPPreviewR_Test1_DblClick
'Variable declaration
Dim stDocName As String
Dim Nb As Integer
Dim Page As Integer
Dim PageTotal As Integer
Dim Dbprtqty As Database
Dim LastPage As Recordset
'Database Name
Set Dbprtqty = Application.CurrentDb
'Report Name
stDocName = "R_ReelLabelsJauneSN"
'Record variable
Set LastPage = Dbprtqty.OpenRecordset("T_PrtQty",
DB_Opentable, DB_READONLY)
'Goto First Record
LastPage.MoveFirst
'Fixe varaible Page to 1 Before Starting the Loop
Page = 1
' Start Loop
Do
'Amount of Pages to Print for that Record
Nb = CLng(Me.Meters) / 2500 + 1
'Print the right Page with the right Qty of Pages
DoCmd.PrintOut stDocName, Page, Page, acHigh, Nb, False
'Prepare for Next Page
Page = Page + 1
'Goto Next Record
LastPage.MoveNext
'Condition to Stop the Loop
Loop Until LastPage.EOF = True
Exit_cmdPPreviewR_Test1_DblClick:
Exit Sub
Err_cmdPPreviewR_Test1_DblClick:
MsgBox Err.Description
Resume Exit_cmdPPreviewR_Test1_DblClick
End Sub
I will appreciate if somebody are able to help me.
Thanks
I have an Access 2000 project link with a SQL Server 2000
database. In my SQL Server I have a table with some fields
who I would like to print but a different page number for
each recordset. So I had type that vba programs to do it
but when the program do the SET LastPage line I receive
that error message: Object variable or With bloc variable
not set.
Private Sub cmdPPreviewR_Test1_DblClick(Cancel As Integer)
On Error GoTo Err_cmdPPreviewR_Test1_DblClick
'Variable declaration
Dim stDocName As String
Dim Nb As Integer
Dim Page As Integer
Dim PageTotal As Integer
Dim Dbprtqty As Database
Dim LastPage As Recordset
'Database Name
Set Dbprtqty = Application.CurrentDb
'Report Name
stDocName = "R_ReelLabelsJauneSN"
'Record variable
Set LastPage = Dbprtqty.OpenRecordset("T_PrtQty",
DB_Opentable, DB_READONLY)
'Goto First Record
LastPage.MoveFirst
'Fixe varaible Page to 1 Before Starting the Loop
Page = 1
' Start Loop
Do
'Amount of Pages to Print for that Record
Nb = CLng(Me.Meters) / 2500 + 1
'Print the right Page with the right Qty of Pages
DoCmd.PrintOut stDocName, Page, Page, acHigh, Nb, False
'Prepare for Next Page
Page = Page + 1
'Goto Next Record
LastPage.MoveNext
'Condition to Stop the Loop
Loop Until LastPage.EOF = True
Exit_cmdPPreviewR_Test1_DblClick:
Exit Sub
Err_cmdPPreviewR_Test1_DblClick:
MsgBox Err.Description
Resume Exit_cmdPPreviewR_Test1_DblClick
End Sub
I will appreciate if somebody are able to help me.
Thanks