Is this possible? *8132008

J

J.Alladien

Hello All,

I have a table with number values like 1-8-25-133 ,is it possible to print
a report in that same DB but only where the pages are 1-8-25-133 (based upon
the table-values ofcourse) ! So the printout or preview should only print
these 4 pages( 1-8-25-133 )

Thanks in advance!
 
P

pietlinden

Hello All,

I have a table with number values like 1-8-25-133  ,is it possible to print
a report in that same DB but only where the pages are 1-8-25-133 (based upon
the table-values ofcourse) ! So the printout or preview should only print
these 4 pages( 1-8-25-133 )

Thanks in advance!

Maybe this will work...
Public Sub ShowRanges()
On Error GoTo ShowRanges_Err

Dim varRange As Variant 'to hold the array of page ranges to print
Dim rsRanges As DAO.Recordset 'source for array of page ranges
Dim i As Integer ' to loop over array (varRange)

Set rsRanges = DBEngine(0)
(0).OpenRecordset("tblPrintReportRanges", dbOpenTable, dbForwardOnly)

Do Until rsRanges.EOF
Debug.Print "Open " & rsRanges.Fields("ReportName") & " and
print page " & rsRanges.Fields("PagesToPrint")
'-- parse out the values in "PagesToPrint"
varRange = Split(rsRanges.Fields("PagesToPrint"), "-")

DoCmd.OpenReport rsRanges.Fields("ReportName")

For i = LBound(varRange) To UBound(varRange)
Debug.Print CInt(varRange(i))
DoCmd.PrintOut acPages, varRange(i), varRange(i),
acHigh, 1
Next i

DoCmd.Close acReport, rsRanges.Fields("ReportName"), acSaveNo


'DoCmd.Close acReport
rsRanges.MoveNext
Loop

rsRanges.Close
Set rsRanges = Nothing

ShowRanges_Exit:
Exit Sub

ShowRanges_Err:
MsgBox Error$
Resume ShowRanges_Exit

End Sub
 
J

J.Alladien

Piet ,

I am not as experienced so please bear with me ;I did the following

Function ShowRanges()
On Error GoTo ShowRanges_Err

Dim varRange As Variant 'to hold the array of page ranges to print
Dim rsRanges As DAO.Recordset 'source for array of page ranges
Dim i As Integer ' to loop over array (varRange)

Set rsRanges = DBEngine(0)(0).OpenRecordset("PRIJZEN_CHECK2",
dbOpenTable, dbForwardOnly)

Do Until rsRanges.EOF
Debug.Print "Open " & rsRanges.Fields("CATALOGUS_ALGEMEEN2D*") & "
and"
Print Page; " & rsRanges.Fields("; PagesToPrint; ")"
'-- parse out the values in "PagesToPrint"
varRange = Split(rsRanges.Fields("PagesToPrint"), "-")

DoCmd.OpenReport rsRanges.Fields("CATALOGUS_ALGEMEEN2D*")

For i = LBound(varRange) To UBound(varRange)
Debug.Print CInt(varRange(i))
DoCmd.PrintOut acPages, varRange(i), varRange(i), acHigh, 1
Next i

DoCmd.Close acReport, rsRanges.Fields("CATALOGUS_ALGEMEEN2D*"),
acSaveNo


'DoCmd.Close acReport
rsRanges.MoveNext
Loop

rsRanges.Close
Set rsRanges = Nothing

ShowRanges_Exit:
Exit Function

ShowRanges_Err:
MsgBox Error$
Resume ShowRanges_Exit

End Function

The table name is "PRIJZEN_CHECK2" , one of the fields in this table is
"PagesToPrint" and the report is "CATALOGUS_ALGEMEEN2D*" when I run this
function i get " Compile error, method not valid without suitable object" in
this line ==> "Print Page; " & rsRanges.Fields("; PagesToPrint; ")" "

is this about a referance that needs to be checked? Pls explain!
 
J

J.Alladien

Piet ,

I also tried the following:

Private Sub PRNT_Click()
On Error GoTo ShowRanges_Err

Dim varRange As Variant 'to hold the array of page ranges to print
Dim rsRanges As DAO.Recordset 'source for array of page ranges
Dim i As Integer ' to loop over array (varRange)


Set rsRanges = DBEngine(0)(0).OpenRecordset("PRIJZEN_CHECK2",
dbOpenTable, dbForwardOnly)

Do Until rsRanges.EOF
Debug.Print "Open " & rsRanges.Fields("CATALOGUS_ALGEMEEN2D*") & "
and"
Print Page; " & rsRanges.Fields("; PagesToPrint; ")"
'-- parse out the values in "PagesToPrint"
varRange = Split(rsRanges.Fields("PagesToPrint"), "-")

DoCmd.OpenReport rsRanges.Fields("CATALOGUS_ALGEMEEN2D*")

For i = LBound(varRange) To UBound(varRange)
Debug.Print CInt(varRange(i))
DoCmd.PrintOut acPages, varRange(i), varRange(i), acHigh, 1
Next i

DoCmd.Close acReport, rsRanges.Fields("CATALOGUS_ALGEMEEN2D*"),
acSaveNo


'DoCmd.Close acReport
rsRanges.MoveNext
Loop

rsRanges.Close
Set rsRanges = Nothing

ShowRanges_Exit:
Exit Sub

ShowRanges_Err:
MsgBox Error$
Resume ShowRanges_Exit



End Sub

When I do this I get foll error: "Compile error ;variable not defined"
where "PagesToPrint" gets highlighted in line "Print Page; " &
rsRanges.Fields("; PagesToPrint; ")" Hope that info helps !
 
S

Stefan Hoffmann

hi,

J.Alladien said:
I have a table with number values like 1-8-25-133 ,is it possible to print
a report in that same DB but only where the pages are 1-8-25-133 (based upon
the table-values ofcourse) ! So the printout or preview should only print
these 4 pages( 1-8-25-133 )
Not really, only if you can predict (calculate) the content of these
pages by its number.

E.g a simple case, say you always print 10 records per page:

Assume this record source:

SELECT
*,
Nz(DCount("*", "yourTable", "id <" & id), 0) AS RowCount
FROM yourTable

Then you can filter
(RowCount >= 0 AND RowCount <= 10) OR
(RowCount >= 80 AND RowCount <= 90) OR
(RowCount >= 250 AND RowCount <= 260) OR
(RowCount >= 1330 AND RowCount <= 1340)


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top