table tSalOrdr ...does it have a flag for the latest copy of the order?

Is there a flag in the table tSalOrdr which indicates the last saved copy of a sales order. I am using SQL to query a sales order and I am finding duplicates which are related to every instance a sales order was saved. But the high Sales Order unique ID would be the latest copy. I am asking this because doing a select with a subselect in the WHERE is the only way I know the return many rows of the same high values in a column. If there was a flag that would make it much easier. Is the flag in another table?
I'm using Mircosoft query in Excel to do this which is not very friendly with the subquery I am adding in the "Where" of my statement. Thank you for your help.
-Nick

  • 0

    Had you shown us your subquery, I could have been able to give you a better answer, but making the assumption that when you said

    Nicpic72 said:
    Is there a flag in the table tSalOrdr which indicates the last saved copy of a sales order...

    You mean you wish to see the current active sales order with the order number xxxx.  tsalordr is the master table in this module.

    If that's the case you can use the field tsalordr.bCleared = 0 to show the latest sales order not yet completely turned into an invoice.

    I don't recall using it myself but you can also use tsalordr.bReversed = 0.

    I haven't checked in a few versions but tsalordr.nFilled = 0 means nothing filled, = 2 partially filled and =1 is fully filled.

    You might use a combination of these to get the data you want.  Although I am also assuming your subquery uses MAX(tsalordr.lId) in some manner so it should work as well to get the latest sales order as long as you are using the sales order number as one of the parameters also in both the main and subquery.

    Don't forget tsalordr.bQuote = 0 or you will get quotes in your data as well as orders.

    Disclaimer: I have not tested this sales order stuff in a few years, that's why I have given you a few options.

  • 0 in reply to Richard S. Ridings
    Thank you for the information. This was quite useful.