UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Skipped Label Appears On Screen But Not On Printout, Access 2016    
 
   
DeborahSV
post Jun 12 2018, 11:47 AM
Post#1



Posts: 99
Joined: 14-September 10



Hello,
I am trying to create labels where the user has the option of skipping the labels on the sheet that have already been used. I tried to adapt code from a report that I made years ago (that I probably originally found here...)
When the report is opened, the user is prompted to say how many labels to skip. When I open in print preview, I see those skipped labels. However, when I then press Print, the labels print from the first one - nothing skipped. If I send the label straight to print (without previewing first), then the labels are appropriately skipped. Below is my code (obviously the second sub runs first.) What am I doing wrong?

Option Compare Database
Option Explicit
Dim intLabelBlanks As Integer
Dim intBlankCount As Integer


Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
On Error GoTo Sub_Error

If intBlankCount < intLabelBlanks Then
Me.NextRecord = False
Me.PrintSection = False
intBlankCount = intBlankCount + 1
End If

Sub_Exit:
Exit Sub
Sub_Error:
MsgBox Err.Description
Resume Sub_Exit
End Sub

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Sub_Error

intLabelBlanks = Nz(Val(InputBox("Please enter the number of blank labels to skip:", "Number of Blank Labels")), 0)
If intLabelBlanks < 0 Then intLabelBlanks = 0

intBlankCount = 0


Sub_Exit:
Exit Sub
Sub_Error:
MsgBox Err.Description
Resume Sub_Exit
End Sub

--
Thank you!
Go to the top of the page
 
RJD
post Jun 12 2018, 11:11 PM
Post#2


UtterAccess VIP
Posts: 8,783
Joined: 25-October 10
From: Gulf South USA


Hi Deborah: I see that no one has jumped in on a solution for your issue (and it has been languishing for a bit), so I'll do that ...

I do not recognize the method you are using to skip labels, so I am attaching a demo for a method I use (and have seen used here at UA before). This method uses a new table of sequence numbers to limit the Null values to start. This is used in conjunction with a UNION query containing your normal label query and a query that inserts the number of "blank" labels based on user input to a prompt. No subs, no code, just SQL and the utility table. You will have to adjust this to your needs, of course, but the basic idea is there.

See if this makes more sense, and solves your view-to-print issue.

HTH
Joe
Attached File(s)
Attached File  SkippedLabel.zip ( 23.99K )Number of downloads: 3
 

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
DeborahSV
post Jun 13 2018, 10:20 AM
Post#3



Posts: 99
Joined: 14-September 10



Thank you so much, Joe! This worked perfectly for me.

I "borrowed" that original code from something I once saw online, but it's not always wise to copy code without fully understanding it...

Your solution is clever and simple, and best of all, I understand it! I had to modify slightly, of course, but my labels are viewing and printing correctly now.

Thanks,
Deborah
Go to the top of the page
 
RJD
post Jun 13 2018, 10:25 AM
Post#4


UtterAccess VIP
Posts: 8,783
Joined: 25-October 10
From: Gulf South USA


You are very welcome, Deborah. Glad that worked for you. thumbup.gif

Good luck with your db.

Regards
Joe

from phone while having coffee at Crazy B's.

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    20th September 2018 - 05:59 AM