Making multiple Invoices automatically

Mario Jaile 41 Reputation points
2021-12-24T15:10:30.787+00:00

I have a form named "RenewalForm" with a query that is not updatable where customer's records that are up for renewals show up.
I have a code under "ShipName" in that form that when I click, it does the invoice and prints it.
Is there a way that I can do all of them without having to click on "ShipName" for each?

Thank you.

Microsoft 365 and Office Access Development
0 comments No comments
{count} votes

21 answers

Sort by: Most helpful
  1. Ken Sheridan 2,851 Reputation points
    2021-12-28T01:04:12.917+00:00

    It should be possible to print all of the invoices as a single report, in which each invoice begins on a new page. Without knowing more about your data it's not possible to be more categorical, but you would need to either filter the report to the relevant invoices by means of the WhereCondtion argument of the OpenReport method, or restrict the report's RecordSource query to the relevant invoices by referencing a control or controls on a form as parameter(s).

    0 comments No comments

  2. Mario Jaile 41 Reputation points
    2021-12-28T15:50:22.11+00:00

    Thank you.

    What about for making the Invoice?

    0 comments No comments

  3. Ken Sheridan 2,851 Reputation points
    2021-12-28T18:32:36.077+00:00

    Normally an invoice is a report whose RecordSource is a query which draws its values from the columns in the relevant tables. The report might include sub-reports. For a single invoice the report would be filtered on an IndexNumber or similar column.

    To print a single report of multiple invoices, therefore, would require the report to be filtered not on IndexNumber but on some other criteria, e.g. a CustomerID and IndexDate, the latter being restricted to a date range defined by start and end date parameters. The following query for instance,

    PARAMETERS Forms!frmInvoice!Customer LONG,
    [Enter start date:] DATETIME,
    [Enter end date:] DATETIME;
    SELECT *
    FROM qryInvoices
    WHERE CustomerID = Forms!frmInvoice!Customer
    AND InvoiceDate BETWEEN [Enter start date:]
    AND [Enter end date:];

    would return all invoices for the current customer in frmInvoice whose dates fall within the range between the start and end dates entered by the user at runtime. The query uses data from InvoicePDF.zip, which you'll find in my public databases folder at:

    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169

    This little demo file is primarily intended to illustrate how to output invoices as PDF files, as its name suggests.

    0 comments No comments

  4. Mario Jaile 41 Reputation points
    2021-12-28T19:07:53.19+00:00

    Thanks you, I really appreciate your time, I still confuse since I have to make the Invoice before I can printed.
    Here is the code I have:
    Private Sub Button124_Click()
    DoCmd.OpenForm "OrderForm"
    DoCmd.GoToRecord acForm, "OrderForm", acNewRec
    Forms!OrderForm!OrderDate = Forms!ColdStorage2323!DateIn
    Forms!OrderForm!ShippedDate = Forms!ColdStorage2323!DateIn
    Sendkey "{ENTER}"
    Sendkey "{ENTER}"
    Forms!OrderForm!CID = Forms!ColdStorage2323!CID
    'Forms!OrderForm!OrderDate = Forms!coldstorage2323!DateIn
    'Forms!OrderForm!ShippedDate = Forms!coldstorage2323!DateIn
    'Sendkey "{ENTER}"
    'Sendkey "{ENTER}"
    'Forms!OrderForm!OrderBy = Forms!coldstorage2323!OrderBy
    Sendkey "{ENTER}"
    Pause (1)
    Forms!OrderForm![EID] = Forms!CurrentUser![Text4]
    Forms![OrderForm]![Notes] = Forms!ColdStorage2323!ProductDescription
    Forms!OrderForm!LotNumber = Forms!ColdStorage2323!LotNumber
    If (IsNull(Forms![OrderForm]![OID])) Then
    Forms![OrderForm]![OID] = DMax("[OID]", "ShipAddress") + 1
    End If
    DoEvents
    DoCmd.GoToControl "OrderSubform"
    Forms![OrderForm]![OrderSubform].Form![Box] = Forms!ColdStorage2323!BoxesIn
    Sendkey "{ENTER}"
    Pause (1)
    Sendkey "{ENTER}"
    Pause (2)
    Sendkey "ZzStorage"
    Pause (2)
    Sendkey "{ENTER}"
    DoCmd.GoToControl "combo280"
    DoCmd.GoToControl "OrderSubform"
    Forms![OrderForm]![OrderSubform].Form![WeightUnits] = Forms![OrderForm]![OrderSubform].Form![Box]
    Forms![OrderForm]![OrderSubform].Form![TWeightUnits] = Forms![OrderForm]![OrderSubform].Form![Box]
    Forms![OrderForm]![OrderSubform].Form![ExtPrice] = Forms!ColdStorage2323!InvAmt
    Forms![OrderForm]![OrderSubform].Form![BoxShip] = Forms![OrderForm]![OrderSubform].Form![Box]
    Forms![OrderForm]![OrderSubform].Form![QShipped] = Forms![OrderForm]![OrderSubform].Form![Box]
    Sendkey "{F9}"
    DoCmd.GoToControl "combo280"
    Forms!OrderForm!FOrderPerson = Forms!CurrentUser!Text4
    DoCmd.GoToControl! "Button76"
    Sendkey "{ENTER}"

    End Sub

    "Button76" is the one that prints the report

    0 comments No comments

  5. Ken Sheridan 2,851 Reputation points
    2021-12-29T18:16:47.477+00:00

    You seem to be inserting data into one form from another. What is unclear is whether those forms are bound or not. If bound, as would be usual in a sales orders/invoices database, you should not be referencing the forma at all, but using a query to retrieve values directly from the tables. This is how my InvoicePDF demo works, based on the following model:

    As you can see this model allows data to be inserted directly into the Invoices and related tables. This is because the demo is designed to illustrate how to output reports (invoices) as PDF files, and is this a simplified model. More usually an operational database of this nature would allow data to be inserted into an orders and related tables. Invoice creation would then follow one of two basic models:

    1. In the simplest model it is assumed that each invoice mirrors a sales order exactly. In this scenario there is no data stored in a separate Invoice table, as the invoice report can be based directly on the Orders and related tables. The Orders table would include Invoiced, InvoiceDate, and InvoicePaid columns.
    2. A more complex model includes separate Invoices and related tables. This allows an invoice to be raised for partial or and/or multiple orders. Each invoice is built by copying the relevant key values from the Orders and related tables by means of 'append' queries.

    You can of course have a model which is somewhere between the above two options, and includes an Invoices and related tables, but with less data inserted from the Orders table and its related tables. The exact model is determined by your business practices.

    Whichever model is used, the point is that the invoice report is based on a query drawing data from the tables, with no reference to forms other than as parameters to restrict the result of the query. Consequently, it is possible to restrict the report in many different ways, so outputting multiple invoices as a single report becomes a simple task, as the sample query I gave you in my last reply illustrates.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.