Newsgroup: it.comp.appl.access
Titolo: evento su stampa

Ciao
l'evento onprint delle sezioni dei report si avvia ogni volta che la sezione
viene efferrivamente mandata in stampa sia che sia a video che in coda di
stampa.
Esiste una variabile di access tipo "acOutput" (?) che mi dica dove sto
stampando? o perlomeno se il report è aperto in preview o meno
giazie

 stampando? o perlomeno se il report è aperto in preview o meno
Copio e incollo...
There are occassions where in your application, you need to know if a report
was printed or previewed in order to allow for some action to be taken after
printing and to not take a similar action (e.g. an update query,) if the
report was only previewed.
To determine this, you can call the following function from your report's
OnClose event. It will return true if the report was previewed, and false if
it was sent to the printer.
If a call to this function returns false, then have your report call a
second subprocedure which sets a module level variable in whatever module
opens the report to act as a flag on whether to take action or not.
The one trick to using this code, is that you should remove the print icons
from both the tool bar and menu for your reports (Do this by creating custom
tool bars and menus) because if the user previews the report and then prints
from the preview, the function will still return a value of true for the
report only being previewed.
(Note this is Access 95/97 syntax, the same api's exist in 16 bit versions
for Access 2, but you would need to change the declares)
Declares:
Private Declare Function GetWindowText _
     Lib "user32" Alias "GetWindowTextA" _
    (ByVal hWnd&, ByVal lpstrTitleBuff$, _
     ByVal intCharstoCopy%) as Long
Private Declare Function GetClassName _
    Lib "user32" Alias "GetClassNameA" _
    (ByVal hWnd As Long, ByVal lpClassName As String, _
     ByVal nMaxCount As Long) As Long
Private Declare Function GetWindow _
     Lib "user32" (ByVal hWnd As Long, _
     ByVal wFlag As Long) As Long
Private Declare Function FindWindowEx _
     Lib "user32" Alias "FindWindowExA" _
    (ByVal hwndParent As Long, ByVal hWndChid As Long, _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As Long
Private Declare Function IsWindowVisible Lib _
     "user32" (ByVal hWndTarget As Long) As Long
Public Function ChkPreview(RptName As String) As Boolean
'-------------------------------------------------------
'Purpose: To see if an Access report is open in preview
'or not (i.e. its opened to print)
'Accepts: Report Name up to 100 characters
'Return: True if in preview, false if not
'Copyright © 1997-98 ATTAC Consulting Group, Ann Arbor, MI USA
'All rights reserved.
'---------------------------------------------------------
On Error GoTo Err_MWC
    Dim Winhwnd&, hWndMIDI&, hWndTarget&
    Dim ClsNameBuff$
    Dim ClsBuffsz%
    Dim TitleBuff As String * 100
    Dim titlestr$
    Dim dwReturn&
    Const TARGET_WINDOW_MIDI = "MDIClient"
    Const TARGET_WINDOW_DB = "OReport"
    Const GW_HWNDNEXT = 2
    Const GW_CHILD = 5
    ClsBuffsz = 30
    ClsNameBuff = Space(ClsBuffsz)
    ChkPreview = False
    Winhwnd = Application.hWndAccessApp
    hWndMIDI = FindWindowEx(Winhwnd, 0&, TARGET_WINDOW_MIDI, vbNullString)
    If hWndMIDI = 0 Then
        'If its not found exit gracefully
        Exit Function
    End If
    'Found the MIDI Client Class, Now find the OReport Class window
    'by looking through children for a report with the like name.
    hWndTarget = GetWindow(hWndMIDI, GW_CHILD)
     While hWndTarget > 0
        dwReturn = GetClassName(hWndTarget, ClsNameBuff, ClsBuffsz)
        If InStr(ClsNameBuff, TARGET_WINDOW_DB) > 0 Then
            dwReturn = GetWindowText(hWndTarget, TitleBuff, 100)
            titlestr = Trim(TitleBuff)
            If InStr(titlestr, RptName) > 0 Then
                dwReturn = IsWindowVisible(hWndTarget)
                If dwReturn = 1 Then ChkPreview = True
                Exit Function
            End If
        End If
        hWndTarget = GetWindow(hWndTarget, GW_HWNDNEXT)
    Wend
Exit_MWC:
    Exit Function
Err_MWC:
    Resume Exit_MWC
End Function
--
Ciao, AntoGal
*************************************************
Home Page (area programmatori di VolFtp)
http://volftp.mondadori.com/italiani/galletta/
per scaricare un gioco di DAMA ITALIANA
*************************************************