Code.GeekInterview.com
 
Code Samples MS Access
 

Generate Invoice Number Series


Code ResourceAuthor: Lokesh M  

Difficulty Level:

Published: 21st Jun 2007   Read: 7612 times  

Filed in: MS Access
Add Comment


 

 

Sponsored Links


 

 

The objective of this function is to generate invoice number in a specified serial format. 

Commonly Invoice Number is stored as number in the database.  While printing Invoice, It is offen required to print invoice numbers in specified format as per customer's requirement.   Most of them would like to have invoice number printed in formats which has 000 as prefix along with financial year and suffix.This function is usefull in such cases.
Generate_Inv_No Function takes in 2 arguments, Invoice Number and Invoice Date and gives the out put in the format Inv / 0001 / 07-08

 


Sample Code
  1.  
  2.  Public Function Generate_Inv_No(XNo As Long, XDate As Date)
  3.     Dim DString As String
  4.     Dim RNo As String
  5.    
  6.     Select Case Len(LTrim(RTrim(Str(XNo))))
  7.         Case 1
  8.             RNo = "000" & LTrim(RTrim(Str(XNo)))
  9.         Case 2
  10.             RNo = "00" & LTrim(RTrim(Str(XNo)))
  11.         Case 3
  12.             RNo = "0" & LTrim(RTrim(Str(XNo)))
  13.         Case 4
  14.             RNo = LTrim(RTrim(Str(XNo)))
  15.         Case Else
  16.             RNo = LTrim(RTrim(Str(XNo)))
  17.     End Select
  18.    
  19.     Select Case Month(XDate)
  20.         Case 1 To 3
  21.             DString = " / " & Mid(Year(XDate) - 1, 3, 2) & "-" & Mid(Year(XDate), 3, 2)
  22.         Case 4 To 12
  23.             DString = " / " & Mid(Year(XDate), 3, 2) & "-" & Mid(Year(XDate) + 1, 3, 2)
  24.     End Select
  25.    
  26.     SType = "Inv / "
  27.    
  28.     Generate_Inv_No = LTrim(RTrim(SType & RNo)) & DString
  29. End Function
  30. Public Function Test_Inv_No()
  31.     Inv_Series = Generate_Inv_No(1, Date)
  32.     MsgBox Inv_Series
  33. End Function
  34.  
Copyright GeekInterview.com


Next Article: Navigation made easy


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    



Comments

Why not:
Generate_Inv_No = "Inv / " & right("0000" & Xno & " / " format(XDate,"MM-YY")
Comment posted by: Bryan on 2010-05-02T13:18:40
Because you are not suppose to hardcode "0000" even before determining the value of "Xno"
Comment posted by: Lokesh M on 2010-05-18T03:15:26

Popular Coders

# Coder NameHits
1. Lokesh M11287
2. Shivanna6117
3. Rajani4931

Active Coders

# Coder NameCodes
1. Shivanna2
2. Lokesh M2
3. Rajani1

Refined Tags