Results 1 to 2 of 2
  1. #1
    Join Date
    May 2006

    Arrow Unanswered: Why same report prints twice

    [B]Dear All,
    I really, really need your help! I woul be so thankful to you all if you could please help me out with this:

    I have a form on which i have a command button to print report. When i select the record that I want to print on a report, then it prints creates the same report twice. It used to work perfectly alright but I dont know why it prints the same report twice. Awkwardly with some of the records it only prints once.

    Can anyone please help me out and email me the response to: . Thank you so much

    by the way below is the code behind the command button:

    Private Sub cmdInvoiceClient_Click()
    Dim strAccountRef As String
    Dim strSQL As String
    Dim intInvoiceExists As Integer
    Dim ReportName As String
    Dim rsNewDetails As New Recordset 'Making a recordest of new entry, to update fields with financial figures

    'Me.Requery - cant use requery since it's based ona query and sorted by date of order
    Me.InvoiceDate = Format(Date, "Medium Date")

    If Len(Me.SageInvNumber) > 0 Then intInvoiceExists = 1

    ' If invoice has already been created for this Booking ID then
    ' tell the user, otherwise create an invoice for this Booking ID.
    If intInvoiceExists = 1 Then
    MsgBox ("An invoice has already been raise for this booking")

    'Create new record in Invoice table
    'The autonumber field becomes the unique Invoice number
    strSQL = "INSERT INTO Invoice ( Bookingid ) SELECT " & Me.AccountRef & ";"
    DoCmd.RunSQL (strSQL)

    temp_SageInvNumber = Generate_Sage_Invoice(Bookingid)
    End If

    'Details for new invoice

    rsNewDetails.Open _
    "SELECT * " & _
    "FROM Booking " & _
    "WHERE id = " & Me.AccountRef, _
    CurrentProject.Connection, adOpenKeyset, adLockOptimistic

    With rsNewDetails
    !InvoiceDate = Me.InvoiceDate
    !WorkHours = Me.WorkHours
    !ClientRate = Me.ClientRate
    !ClientExpenses = Me.ClientExpenses
    !JourneyMiles = Me.JourneyMiles
    !ClientRatePerMile = Me.ClientRatePerMile
    !ClientAmountLessVAT = Me.txtClientAmount
    If Len(temp_SageInvNumber) > 0 Then
    !SageInvNumber = temp_SageInvNumber
    End If
    End With

    'Steve - EBS - 16-11-05
    temp_SageInvNumber = ""

    'Print InterpreterInvoice
    ReportName = "rptInvoiceClient"
    DoCmd.OpenReport _
    ReportName:=ReportName, _
    View:=acViewPreview, _
    wherecondition:=" = " & Me.AccountRef
    'View:=acViewPreview to preview the fax
    'View:=acViewNormal to print the fax

    End Sub

  2. #2
    Join Date
    Oct 2003
    Provided Answers: 1
    Did you try:

    DoCmd.OpenReport "rptInvoiceClient", acPreview,," = " & Me.AccountRef

Posting Permissions

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