Rabu, 21 September 2011

[MS_AccessPros] Re: How to know if a report has printed

 

A.D.

Very clever (as usual from you). This appears to be what I am looking for. I won't be able to try it until next week. I'll let you know if I need any more help.

Thanks

Adam

--- In MS_Access_Professionals@yahoogroups.com, "A.D. Tejpal" <adtp@...> wrote:
>
> Adam,
>
> You wish to ensure that if the user attempts to take out a print while the report is in preview mode, a suitable message should come up if a print for such a report has already been taken.
>
> The desired objective can be realized by making use of the fact that Activate event fires only if the report is opened in preview mode, while second firing of print event of report header section when the report has so far been in preview mode, signifies transition to print mode.
>
> It is to be noted that report's open event does not fire afresh, when printing is carried out while it is open in preview mode.
>
> Sample code in report's module in conjunction with a few global variables declared in general module as given below, should get you the desired results. For your ready reference, sample db named Report_DetectPrintState.zip uploaded to Samples folder in Files section demonstrates the suggested approach.
>
> You might like to try it out (in the first stage, as it is, without attempting any modifications) and confirm whether the outcome is in line with your requirements.
>
> Note:
> (a) If report header section is empty, it should be ensured that its height is tangible. Otherwise, the print event for this section won't fire.
> (b) Print history is maintained in table T_PrintLog. On first printing it gets done silently. For subsequent attempts, preliminary warning comes up on opening the report in preview mode.
> (c) If despite earlier warning, the user inadvertently clicks the print button, a second prompt comes up just on commencement of print action. If user's response (whether to go ahead with printing) is No, a blank page goes in and out of the printer.
> (d) The sample db mentioned above, is in Access 2000 file format, developed on Access 2003 installation.
>
> Best wishes,
> A.D. Tejpal
> ------------
>
> ' Code in general module
> '=====================
> ' Declaratios section
> Public mPreview As Boolean
> Public mCancelPrint As Boolean
> Public mRptHdrPrintCount
> Public mLastPrintDt As Variant
> '=====================
>
> ' Code in report's VBA module
> '=====================
> Private Sub Detail_Format( _
> Cancel As Integer, FormatCount As Integer)
> Cancel = mCancelPrint
> End Sub
> '-------------------------------
>
> Private Sub PageFooterSection_Format( _
> Cancel As Integer, FormatCount As Integer)
> Cancel = mCancelPrint
> End Sub
> '-------------------------------
>
> Private Sub PageHeaderSection_Format( _
> Cancel As Integer, FormatCount As Integer)
> Cancel = mCancelPrint
> End Sub
> '-------------------------------
>
> Private Sub Report_Activate()
> ' Set global (in general module) confirming
> ' preview state
> mPreview = True
>
> mLastPrintDt = DMax("PrintDtTime", _
> "T_PrintLog", "ReportName = '" & _
> Me.Name & "'")
>
> If Not IsNull(mLastPrintDt) Then
> MsgBox "This report has already been printed on: " & _
> Format(mLastPrintDt, "dd-mmm-yyy " & _
> "hh:nn:ss")
> End If
>
> ' Note:
> ' Report's Activate event fires only in
> ' preview mode
> End Sub
> '-------------------------------
>
> Private Sub Report_Close()
> ' Assign default value to global variable
> ' (in general module)
> mPreview = False
> mRptHdrPrintCount = 0
> mCancelPrint = False
> mLastPrintDt = Null
> End Sub
> '-------------------------------
>
> Private Sub Report_Open(Cancel As Integer)
> ' Assign default value to global variable
> ' (in general module)
> mPreview = False
> mRptHdrPrintCount = 0
> mCancelPrint = False
> mLastPrintDt = Null
> End Sub
> '-------------------------------
>
> Private Sub ReportFooter_Format( _
> Cancel As Integer, FormatCount As Integer)
> Cancel = mCancelPrint
> End Sub
> '-------------------------------
>
> Private Sub ReportHeader_Format( _
> Cancel As Integer, FormatCount As Integer)
> If mRptHdrPrintCount > 0 And _
> mPreview <> False Then
> ' It is print after preview
> If Not IsNull(mLastPrintDt) Then
> If MsgBox("This report was last printed on: " & _
> Format(mLastPrintDt, "dd-mmm-yyy " & _
> "hh:nn:ss") & vbCrLf & "Shall Continue " & _
> "With This Print?", vbYesNo) = vbYes Then
> mCancelPrint = False
> Else
> mCancelPrint = True
> Cancel = True
> End If
> End If
>
> ' The report is transitioned to print state
> ' Set the global mPreview to False so as to prevent
> ' repeat popping up of above msg box if rep hdr
> ' format event happens to fire again.
> mPreview = False
> End If
> End Sub
> '-------------------------------
>
> Private Sub ReportHeader_Print( _
> Cancel As Integer, PrintCount As Integer)
> Dim Qst As String
>
> If mCancelPrint = False Then
> mRptHdrPrintCount = mRptHdrPrintCount + 1
> If mRptHdrPrintCount > 1 Then
> ' It is print after preview
> ' Make entry in table T_PrintLog
> Qst = "INSERT INTO T_PrintLog " & _
> " (ReportName, PrintDtTime) " & _
> " VALUES ('" & Me.Name & "', Now());"
> CurrentDb.Execute Qst, dbFailOnError
> End If
> Else
> Cancel = True
> End If
> End Sub
> '================================
>
> ----- Original Message -----
> From: Duane Hookom
> To: Access Professionals Yahoo Group
> Sent: Tuesday, September 20, 2011 08:39
> Subject: RE: [MS_AccessPros] Re: How to know if a report has printed
>
>
> I don't mess with menues. If you had a field that could be set to True if printed, there are a number of ways prevent this record from appearing in the print or print preview.
>
> Duane Hookom
> MS Access MVP
>
>
> To: MS_Access_Professionals@yahoogroups.com
> From: runuphillracing@...
> Date: Mon, 19 Sep 2011 22:33:13 +0000
> Subject: [MS_AccessPros] Re: How to know if a report has printed
>
> Duane,
>
> I didn't try to code. I don't have a field, but could easily add one. I was hoping that was something I could do when they actually printed it. Lacking that, I didn't see the point of adding the field or trying the code.
>
> Lacking that, would it be possible to disable the Print option from the pull-down menus, create my own custom print icon (I know I can hide the standard print icon) that would initiate code to check to see if the batch has been printed, print the report and mark the batch as being printed if not, and send a message if it has been marked? I know how to refer to a Macro from a custom icon. I don't know how to point it to VB code though.
>
> Adam
>
> --- In MS_Access_Professionals@yahoogroups.com, Duane Hookom <duanehookom@> wrote:
> >
> > Adam,
> > Do you have any field in your table that identifies if a record has been printed?
> > Did you at least try the code to see if the MsgBox matches your expectation of printing vs previewing?
> >
> > Duane Hookom
> > MS Access MVP
> >
> >
> > To: MS_Access_Professionals@yahoogroups.com
> > From: runuphillracing@
> > Date: Mon, 19 Sep 2011 20:42:38 +0000
> > Subject: [MS_AccessPros] Re: How to know if a report has printed
> >
> > Duane,
> >
> > Where would I put this code? There is no "OnPrint" for reports.
> >
> > The way it's done now, the report is brought up in Preview mode so they can review the labels before printing (that's how they want it now). Then they print from there (using Ctrl-P or the printer icon). There's nothing in the system that would prevent them from printing repeated times from the Preview mode until they close the report. Once closed, they can't bring up those labels again.
> >
> > Adam
> >
> > --- In MS_Access_Professionals@yahoogroups.com, Duane Hookom <duanehookom@> wrote:
> > >
> > >
> > > I generally recommend prompting the user with a msgbox following the printing like:
> > >
> > > If msgBox("Did these labels successfully print?",vbYesNo+vbQuestion,"Labels Printed") = vbYes then
> > > currentdb.Execute "UPDATE ... ", dbFailOnError
> > > End If
> > >
> > > FredG posted something a number of years ago that might work. You would need to replace the MsgBox with some type of update query.
> > >
> > > Option Compare Database
> > > Option Explicit
> > > Dim intPreview As Integer
> > >
> > > Private Sub Report_Activate()
> > > intPreview = -1 ' If [Pages] is not used
> > > ' intPreview = -2 ' If [Pages] used
> > > End Sub
> > >
> > > Private Sub ReportHeader_Format(Cancel As Integer, FormatCount As Integer)
> > > If intPreview >= 0 Then ' If [Pages] not used
> > > ' If intPreview >= 1 Then ' If [Pages] used
> > > MsgBox "Gone Printing"
> > > End If
> > > intPreview = intPreview + 1
> > > End Sub
> > >
> > > Duane Hookom
> > >
> > >
> > > To: MS_Access_Professionals@yahoogroups.com
> > > From: runuphillracing@
> > > Date: Mon, 19 Sep 2011 19:49:50 +0000
> > > Subject: [MS_AccessPros] Re: How to know if a report has printed
> > >
> > > No.
> > >
> > > Adam
> > >
> > > --- In MS_Access_Professionals@yahoogroups.com, "luvmymelody" <luvmymelody@> wrote:
> > > >
> > > >
> > > > Adam
> > > >
> > > > Did you ever find the solution to your question?
> > > >
> > > > Jim Wagner
> > > >
> > > >
> > > > --- In MS_Access_Professionals@yahoogroups.com, "AdamF" <runuphillracing@> wrote:
> > > > >
> > > > > Is there a way to mark a report when it prints (at least when sent to a printer rather than just preview) so that it doesn't get reprinted?
> > > > >
> > > > > Printing bar code labels. Each label has a unique number, so I don't want them to print it twice. I know I can mark it in the code I use to print the labels if it were printed directly from that code. However, they want it to display in preview mode, then to print from there.
> > > > >
> > > > > Adam
> > > > > Denver, CO
>
> [Non-text portions of this message have been removed]
>

__._,_.___
Recent Activity:
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar