Need a VBA code that will automatically generate a 5 digit number in the form of (month "-" and sequence) ie: 06-150 or 12-873. I need this number to automatically reset to 001 when the month changes. The database I am working with is Access 2002. I just need the VBA code and EXPLICIT instructions as to how to set up the table and the install the code. I am very new to VB so please dont take for granted I will know certain steps. This is a small part of a much larger project. So if the work is fast, fairly priced and well executed, we will have more projectys to discuss.
Here is the code that I have worked on myself
Option Compare Database
Private Sub cmd1_Click()
Dim LocalConnection As [login to view URL]
Dim rJN As [login to view URL]
Dim cMonth As Integer
Dim cYear As Integer
Dim vYear As Integer
Dim vMonth As Integer
Dim vNum As Integer
Set LocalConnection = CurrentDb()
Set rJN = [login to view URL]("TEST")
[login to view URL]
vYear = Val(Left$(rJN(0), 2))
vMonth = Val(Mid$(rJN(0), 3, 2))
vNum = Val(Right$(rJN(0), 3))
cYear = Year(Now)
cMonth = Month(Now)
If vMonth = cMonth Then
rJN(0) = rJN(0) + 1
Else
[login to view URL](0) = (cMonth) + (cYear) + ("001")
End If
[login to view URL] = rJN(0)
End Sub
There are problems with this code and it is not returning the result I need. The number generated in the table should be (month, year and sequence) ie 082003500 and the number visible needs to be 08-500. I haven't worked on that part yet because I am having too many problems with the number generating part.
thanks
## Deliverables
Code snippet and Very Cleear instructions as to how to set it up. Complete ownership and distribution copyrights to all work purchased.
## Platform
VBA