Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples MS Access
 

Generate Invoice Number Series


Code ResourceAuthor: Lokesh M  

Difficulty Level:

Published: 21st Jun 2007   Read: 2788 times  

Filed in: MS Access
Add Comment


 


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 Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. Lokesh M4414
2. Shivanna2234
3. Rajani1515

Active Coders

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

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape