Results 1 to 3 of 3
  1. #1
    crxftw is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    30

    Button to generate InvoiceID and save it for specific records

    Hello! I have a database that contains sales done to the clients and I am working on invoice printing function. The idea is that on client details page I have 'Print Invoice' button which runs query that requests all data from this client sales whos details are open where checkbox 'Invoiced' = False and puts all data returned to report form which will be saved as PDF. When file is successfully saved 'Invoiced' will be set to 'True". Before that I run append query that should generate new field onto 'invoices' table and it also shows this invoiceid on the report. The problem I have is that when I add new sales or for testing purpose removed change 'Invoiced' to False under 'sales' table and run 'Print Invoice' again then this generated id via append will be overwritten and every time I press it I get same invoiceid for every report.



    What I like to know how I can generated invoiceid before report is made and pin this invoiceid to the sales that were selected in case to keep track in future that what sales belong to that invoice or something.

    Hope you understood and can help me, will include code if needed.


    Regards

  2. #2
    Rhino373 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Posts
    65
    So I'll be honest I'm not entirely following what is occuring but it appears you're problem can be fixed in your append statement. You appear to be replacing ALL generated IDs rather than just those that are null. You shouldn't be generating an entire new column just the ID itself. The ID column should already exist in the Invoices table. So in your append your criteria should be "Is Null". This will only generate an ID for "New" entries that don't already have an ID.

    Technically your ID field should be an AutoNumber field where it is populated for you each time a new sale is entered.

    You should have a clients table that has an AutoNumber and that's how you'll relate any invoices to that client. Your invoices table should have an InvoiceID field and a cross reference field that contains the client ID to reference it back to a client.

    If you don't wish the InvoiceID to be an AutoNumber but to be custom based on criteria of the sale, it needs to be created at the time the new sale entry is created not when you are ready to print reports.

  3. #3
    crxftw is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    30
    Hello, 'invoices' table has InvoicesID as autonumber, after that comes clientid from clients table, area from clients table which is prefix for invoice, status which will be set to 'Unpaid' as default, date which is current Date().

    Append query SQL:
    INSERT INTO invoices ( clientid, area, date, status )
    SELECT qryInvoiceClient.clientid, qryInvoiceClient.area, Date() AS Date, "Unpaid" AS Status
    FROM qryInvoiceClient
    GROUP BY qryInvoiceClient.clientid, qryInvoiceClient.area, Date(), "Unpaid";

    qryInvoiceClient:
    SELECT sales.clientid, clients.area
    FROM clients INNER JOIN sales ON clients.clientid = sales.clientid
    WHERE (((sales.completed)=True) AND ((sales.invoiced)=False));
    Last edited by crxftw; 06-09-2011 at 09:49 AM. Reason: quotes

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Button to open on specific Data
    By glasgowlad1999 in forum Access
    Replies: 6
    Last Post: 05-15-2011, 03:46 PM
  2. Save button say syntax error
    By venu_resoju in forum Forms
    Replies: 6
    Last Post: 02-14-2011, 02:52 AM
  3. Replies: 7
    Last Post: 10-27-2010, 12:02 PM
  4. Help Require (Macro Save button )?????
    By aligahk06 in forum Access
    Replies: 1
    Last Post: 04-18-2010, 08:38 AM
  5. Save to PDF Button?
    By SpeedyApocalypse in forum Forms
    Replies: 2
    Last Post: 04-10-2010, 06:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums