Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2004
    Posts
    16

    Unanswered: Printout -prints report and form - I just want report

    --------------------------------------------------------------------------------

    i use this code it work fine . my problem is if no data i got my form print as number of rows x2.


    CODE
    Private Sub cmdPrint5_Click()
    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    Dim stDocName As String
    DoCmd.OpenReport "affichage", acViewPreview, WhereCondition:=" PrintYesNo = False and notification=false "
    DoCmd.SetWarnings False
    DoCmd.SelectObject acReport, "affichage"
    DoCmd.PrintOut acPages, , , , 2
    DoCmd.Close acReport, "affichage"
    DoCmd.RunSQL "Update tbl1 set PrintYesNo = true where PrintYesNo = false "
    DoCmd.SetWarnings True
    End If
    End Sub


    any help please

  2. #2
    Join Date
    Feb 2004
    Posts
    137
    Try this:
    Code:
    Private Sub cmdPrint5_Click()
    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    Dim stDocName As String
    DoCmd.OpenReport "affichage", acViewPreview, WhereCondition:=" PrintYesNo = False and notification=false "
    DoCmd.SetWarnings False
    If Reports("affichage").CurrentRecord Then
        DoCmd.SelectObject acReport, "affichage"
        DoCmd.PrintOut acPages, , , , 2
    End If
    DoCmd.Close acReport, "affichage"
    DoCmd.RunSQL "Update tbl1 set PrintYesNo = true where PrintYesNo = false "
    DoCmd.SetWarnings True
    End If
    End Sub

  3. #3
    Join Date
    Jan 2004
    Posts
    16
    sorry don't no change, same problem, i put a copy of my db
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2004
    Posts
    137
    First of all, I see that your attachment did not include the change I suggested.

    Second, if your going to open the form in Modal view, without setting the form's visible property to False when you go to print, you're going to have the problem you described.

  5. #5
    Join Date
    Jan 2004
    Posts
    16
    i have the same resut with yor suggest

  6. #6
    Join Date
    Feb 2004
    Posts
    137
    Did you also set the form's Modal property to No?

  7. #7
    Join Date
    Jan 2004
    Posts
    16

    Angry

    yes i have do it , when i added new data and click on the print button it work fine, but when i try with no data the forme is printed

  8. #8
    Join Date
    Jan 2004
    Posts
    16
    Matthew Reeves thanx for yur help , the solution was with this code

    Private Sub cmdPrint5_Click()
    On Error Resume Next
    DoCmd.RunCommand acCmdSaveRecord
    If DCount("*", "tbl1", "PrintYesNo=False AND notification=False") > 0 Then
    DoCmd.OpenReport "affichage", acViewPreview, , "PrintYesNo=False AND notification=False"
    DoCmd.SetWarnings False
    DoCmd.SelectObject acReport, "affichage"
    DoCmd.PrintOut acPages, , , , 2
    DoCmd.Close acReport, "affichage"
    DoCmd.RunSQL "Update tbl1 set PrintYesNo = true where PrintYesNo = false "
    DoCmd.SetWarnings True
    End If
    End Sub


    work fine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •