Subject Re: Invoice number
From Bami Onwu <bamionwu@yahoo.com>
Date Mon, 07 Sep 2020 09:59:40 -0400
Newsgroups dbase.getting-started

Thanks to everyone of you.

Akshat please can you attach a brief example of this in a form?. I will quite appreciate.

Thank you.
Bami


Akshat Kapoor Wrote:

> On 06.09.2020 04:59, Bami Onwu wrote:
> > Hi all,
> >
> > I created invoicing app for a customer and it's working fine on standalone. When working under multiuser, it assigns one invoice number to two users.
> >
> > The invoice numbering is no more unique. I need advice on how to go about this.
>
> Good Evening Bami,
> We do not have any info as to when and how new invoice numbers are being
> generated. So cannot say for sure but I agree with Ken that do not
> generate invoice numbers before hand. Generate them at the last moment
> before actual saving of row.
>
> I have been using this system for the past 15+ years and never had any
> issue.
>
> Before that I also used to face this issue but ever since this system
> has been implemented never faced this issue.
>
> Some info regarding this system.
> When a user clicks on new invoice button I assign -1 as the invoice number.
> (If you assign last number +1 here there will always be issues due to
> the time gap involved in assigning and saving of first row with that value)
> The text where invoice number is displayed uses iif
>
> form.header.cash_no.text = "Invoice No. <font color='red'><b>"+
> iif(form.minvoice = -1 , "new" , form.minvoice)        + "</b></font> "
>
> So the user does not feel awkward that how come a new number is -1
>
> In the save pushbutton event I use the following line
> form.minvoice = iif(form.minvoice>0 , form.minvoice ,form.last()+1 )
>
> i.e. if form.invoice (my invoice number) is greater than 0 i.e valid
> then no change otherwise fetch the last Invoice number from the table
> and increment it by 1 before using it.
>
> function last()
> local mcount
> form.salesdatamodule1.last.requery()
> mcount = form.salesdatamodule1.last.rowset.fields["numb"].value
> if mcount = null
> //mcount will be null when there are no rows in the table
>         mcount = 0
> endif
> return mcount
>
>
> SQL for query last
> Select max(invoice_no) as numb from sales WHERE mast <>0
>
> The codes being used are according to my needs and are for example only.
> Make changes according to your own need.
>
> There should not be any gaps in invoice numbering and there should not
> be duplicates are the two key necessary requirements of an invoicing
> system. To achieve this there should be bare minimum time gap between
> generating new invoice number and saving the first row so that the next
> person who generates new invoice number is assigned a new number.
>
> Regards
> Akshat