Don't generate the number in advance. More than one user will generate the same invoice number. Instead generate the Invoice number at the time of inserting the record into the database
INSERT INTO [cust](InVoiceNumber,..,..,..) values (SELECT Max (custno) from [cust],..,..,..)