IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

Impression individuelle de chaque page d'un etat


Sujet :

VBA Access

  1. #1
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut Impression individuelle de chaque page d'un etat
    Bonjour,

    Je suis confronté à la problématique suivante :

    Mon etat (rapport) se constitue de plusieurs pages et a l'impression chacune doit etre imprimée (ex 3 fois)
    L'impression doit donc etre
    Etat feuille 1 ---> imprimer 3 fois
    Etat feuille 2 ---> imprimer 3 fois
    ...

    Pour l'instant , il imprime l'etat complet 3 fois

    Quelqu'un peut m'aider ?

  2. #2
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    Regarde l'aide debon w-e
    "Always look at the bright side of life." Monty Python.

  3. #3
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut C'est ca qui'il faut faire ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    Public Sub PrintReportToPrinter(ReportName As String, strPrinter as string, id As Long)
     
     
        Dim rpt As Report
        Dim prtr As Printer
     
        Set db = CurrentDb
     
        On Error GoTo ShowPrinters_Err
     
        Set Application.Printer = Nothing
     
     
        Set prtr = Application.Printers(strPrinter)
     
        With prtr
                        .PaperBin = 260
                        .Copies = 3
                        .Duplex = acPRDPSimplex
     
        End With
     
        DoCmd.OpenReport ReportName, acViewPreview, , "[Num_tour] =" & id, acHidden
     
         Set rpt = Reports(ReportName)
         rpt.Printer.PaperBin = prtr.PaperBin
         rpt.Printer.Copies = prtr.Copies
         rpt.Printer.Duplex = prtr.Duplex
     
        DoCmd.PrintOut acPages, , , , 3, False                   'C'est ca ?
     
     
        DoCmd.Close acReport, ReportName, acSaveNo
     
     
        Set prtr = Nothing
        set rpt = nothing
     
     
        Set Application.Printer = Nothing
     
     
    End Sub

  4. #4
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    As-tu seulement commencé à faire des essais ?

    Cette faq devrait t'aider
    https://access.developpez.com/faq/?p...ressionEtatPpP
    "Always look at the bright side of life." Monty Python.

  5. #5
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut Impression
    Oui, j'essaie mais je n'y arrive pas

    Chaque fois, l'impression se fait sur l'ensemble et en aucune manière sur chaque page

    Ma requete me retourne x records
    Mais je veux imprimer le 1er 3 fois consecutivement ensuite le 2ème 3 consécutivement , etc

    Mais il imprime le resultat global x fois consecutivement

  6. #6
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    Alors je viens d'en faire l'essai, ça marche
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    Private Sub test_print_page_N_fois()
    Dim i As Long, sDoc As String
    sDoc = "E_article"
    DoCmd.OpenReport sDoc, acViewPreview
    For i = 1 To Reports(sDoc).Pages
    ' imprimer chaque page 2 fois
        DoCmd.PrintOut acPages, i, i, , 2
    Next
    DoCmd.Close acReport, "E_article"
    End Sub
    Bon essai
    "Always look at the bright side of life." Monty Python.

  7. #7
    Modérateur
    Avatar de bertiny
    Homme Profil pro
    Enseignant
    Inscrit en
    Mars 2013
    Messages
    1 282
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2013
    Messages : 1 282
    Points : 1 831
    Points
    1 831
    Billets dans le blog
    1
    Par défaut
    Bonjour

    Code VBA : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    Dim i As Long
    Dim j As Long
    DoCmd.OpenReport "Num_tour", acViewPreview
    For i = 1 To Reports("Num_tour").Pages
        For j = 1 To 3
        DoCmd.PrintOut acPages, i, i
        Next
    Next
    DoCmd.Close acReport, "Num_tour"
    Le monde évolue et nous avec. La technologie change les idées de ceux qui s'intéressent et pensent qu'il est nécessaire de changer.
    Oh là!! Que c'est bien de trouver la solution à un problème

    Pensons à améliorer nos connaissances en toute humilité car on apprend tous tous les jours !!!

  8. #8
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut
    Moi le contenu de Reports("Num_tour").Pages est toujours 0

  9. #9
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    Public Sub PrintReportToPrinter(ReportName As String, id As Long)
     
        Dim db As DataBase
        Dim rs As Recordset
        Dim rpt As Report
        Dim prtr As Printer
     
        Set db = CurrentDb
     
        On Error GoTo ShowPrinters_Err
     
           Set Application.Printer = Nothing
     
           If EvaluateField(Forms!NavBar!Text_depotid) Then
                'Set rs = db.OpenRecordset("SELECT * FROM planisto_transport_imprimantes WHERE depotid = 5  and ReportName = '" & ReportName & "'")
     
                Set rs = db.OpenRecordset("SELECT * FROM planisto_transport_imprimantes WHERE depotid = " & Forms!NavBar!Text_depotid & " and ReportName = '" & ReportName & "'")
                'DoCmd.OpenReport stDocName, View:=acViewPreview, WindowMode:=acHidden
                'Set Reports(stDocName).Report.Printer = Application.Printers(1)
                strPrinter = rs("printername")
                strPrinter2 = rs("printername2")
     
                Set prtr = Application.Printers(strPrinter)
                GoTo Next5
    Error5:
                Set prtr = Application.Printers(strPrinter2)
    Next5:
     
                If EvaluateField(rs("printerdrawer")) Then
     
                    'Set prtr = Application.Printers(strPrinter)
                    With prtr
                        .PaperBin = rs("printerdrawer")
                        .Copies = rs("copies")
                        .Duplex = acPRDPSimplex
                        '.Duplex = acPRDPHorizontal
                        '.Duplex = acPRDPVertical
     
                    End With
                Else
                    'Set prtr = Application.Printers(strPrinter)
     
                    With prtr
                        .PaperBin = acPRBNAuto
                        .Copies = rs("copies")
                        .Duplex = acPRDPSimplex
                        '.Duplex = acPRDPHorizontal
                    End With
                End If
     
                'Set the default printer's paper bin to manual and paper size to legal
                'prtr.PaperBin = acPRBNManual
                'prtr.PaperSize = acPRPSLegal
     
                Set Application.Printer = prtr
     
     
                'open your report in hidden view to aplly print settings
                If id > 0 Then
                    DoCmd.OpenReport ReportName, acViewPreview, , "[Num_tour] =" & id, acHidden
                Else
                    DoCmd.OpenReport ReportName, acViewPreview, , , acHidden
                End If
     
                Msg = "There are " & Reports(ReportName).Pages & " Pages to be printed." 
                ipages = Reports(ReportName).Pages
     
                Set rpt = Reports(ReportName)
     
                rpt.Printer.PaperBin = prtr.PaperBin
                rpt.Printer.Copies = prtr.Copies
                rpt.Printer.Duplex = prtr.Duplex
     
                'Print Report
                DoCmd.OpenReport ReportName
     
     
                'Set the Printer property of the report to the Application.Printer object
                Set rpt.Printer = prtr
                'now open the report in normal view to print
                'DoCmd.OpenReport ReportName, acViewNormal, , "[Num_tour] =" & id
                'DoCmd.PrintOut acPages, , , , 3, False
                'DoCmd.Close acReport, ReportName, acSaveNo
                Set rpt = Nothing
     
                DoCmd.Close acReport, ReportName, acSaveNo
     
     
                Set Application.Printer = Nothing
     
            End If
     
    ShowPrinters_End:
        Exit Sub
     
    ShowPrinters_Err:
        If Err.Number = 5 Then
            GoTo Error5
        Else
            MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
            Title:="Error Number " & Err.Number & " Occurred"
            Resume ShowPrinters_End
        End If
     
     
    End Sub

  10. #10
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    le code ci-aprés (ton code corrgé avec ce que j'avais proposé ci-dessus) fonctionne chez moi.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    Private Sub testReportToPrinter()
    Call PrintReportToPrinter("E_article", 1)
    End Sub
     
    Public Sub PrintReportToPrinter(ReportName As String, id As Long)
     
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim rpt As Report
    Dim prtr As Printer
     
    Set db = CurrentDb
     
    On Error GoTo ShowPrinters_Err
     
    ' ...
     
    'Set the Printer property of the report to the Application.Printer object
    '''Set rpt.Printer = prtr
    'now open the report in normal view to print
    'DoCmd.OpenReport ReportName, acViewNormal, , "[Num_tour] =" & id
    DoCmd.OpenReport ReportName, acViewPreview
    Dim i As Integer
    '''DoCmd.PrintOut acPages, , , , 2, False
        For i = 1 To Reports(ReportName).Pages
            ' imprimer chaque page 2 fois
            DoCmd.PrintOut acPages, i, i, , 2
        Next
    DoCmd.Close acReport, ReportName, acSaveNo
    '''Set rpt = Nothing
     
    'Set Application.Printer = Nothing
     
    'End If
     
    ShowPrinters_End:
    Exit Sub
     
    ShowPrinters_Err:
    If Err.Number = 5 Then
    'GoTo Error5
    Else
    MsgBox Prompt:=Err.Description, Buttons:=vbCritical & vbOKOnly, _
    Title:="Error Number " & Err.Number & " Occurred"
    Resume ShowPrinters_End
    End If
     
    End Sub
    Pour avoir les n° de page, faut ouvrir le report avec
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    DoCmd.OpenReport ReportName, acViewPreview
    Petit tétu
    "Always look at the bright side of life." Monty Python.

  11. #11
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut
    Bonjour

    dans mon cas le nombre de pages est toujours à 0

  12. #12
    Modérateur
    Avatar de bertiny
    Homme Profil pro
    Enseignant
    Inscrit en
    Mars 2013
    Messages
    1 282
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2013
    Messages : 1 282
    Points : 1 831
    Points
    1 831
    Billets dans le blog
    1
    Par défaut
    En affichant l'aperçu de ton état, combien de pages contient-il?
    Le monde évolue et nous avec. La technologie change les idées de ceux qui s'intéressent et pensent qu'il est nécessaire de changer.
    Oh là!! Que c'est bien de trouver la solution à un problème

    Pensons à améliorer nos connaissances en toute humilité car on apprend tous tous les jours !!!

  13. #13
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut
    Des que j'arrive sur une commande docmd.printout
    Je sors de ma procedure
    Images attachées Images attachées  

  14. #14
    Candidat au Club
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Mai 2009
    Messages
    10
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2009
    Messages : 10
    Points : 4
    Points
    4
    Par défaut
    Il y en a 4 !
    Images attachées Images attachées  

  15. #15
    Modérateur
    Avatar de bertiny
    Homme Profil pro
    Enseignant
    Inscrit en
    Mars 2013
    Messages
    1 282
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Cameroun

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Mars 2013
    Messages : 1 282
    Points : 1 831
    Points
    1 831
    Billets dans le blog
    1
    Par défaut
    En voyant tes images, tu as visiblement une erreur. Quel est le message d'erreur que tu as?
    Le monde évolue et nous avec. La technologie change les idées de ceux qui s'intéressent et pensent qu'il est nécessaire de changer.
    Oh là!! Que c'est bien de trouver la solution à un problème

    Pensons à améliorer nos connaissances en toute humilité car on apprend tous tous les jours !!!

  16. #16
    Expert confirmé

    Homme Profil pro
    consultant développeur
    Inscrit en
    Mai 2005
    Messages
    2 878
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : consultant développeur
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mai 2005
    Messages : 2 878
    Points : 4 754
    Points
    4 754
    Par défaut
    De mon côté, je n'ai pas fait de test avec ton code .printer

    J'ai utilisé dans le passé ceci qui fonctionnait bien
    Reports(ReportName).Printer.Duplex = acPRDPSimplex
    "Always look at the bright side of life." Monty Python.

Discussions similaires

  1. [WD20] imprime etat avec nombre enregistrements pour chaque page
    Par hadaf dans le forum WinDev
    Réponses: 5
    Dernier message: 31/12/2017, 00h41
  2. [AC-2003] nbre de ligne pour chaque page dans un etat
    Par akrimi08 dans le forum IHM
    Réponses: 5
    Dernier message: 07/04/2010, 10h38
  3. [AC-2003] Impression de la première page d'un etat
    Par Marc_27 dans le forum IHM
    Réponses: 2
    Dernier message: 16/03/2010, 11h46
  4. Etat avec pages blaches entre chaque page
    Par petitours dans le forum Access
    Réponses: 2
    Dernier message: 15/03/2006, 19h45
  5. Réponses: 3
    Dernier message: 06/01/2006, 15h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo