Solved

Setting Serial numbers back to 1 (automatically) at the beginning of Year.

Posted on 2001-06-04
8
151 Views
Last Modified: 2010-05-02
I developed a few Databases (msaccess) with vb frontends. Every year I manually set the tracking numbers to 001.  However, I will be leaving my position in the near future and I want to leave the company with programs that need no user intervention if possible.  The serial number is 3 digits long, show the leading 0's (ex:001).  Can someone lead me in the right directon.  Everytime I think I have the answer, there is a loop hole somewhere.

Your assistance is greatly appreciated.

Vannms
0
Comment
Question by:vannwms
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 3

Accepted Solution

by:
RodStephens earned 50 total points
ID: 6152611
I'm not sure which of this you need help with, but I can at least help with printing leading zeros.

    Format$(the_value, "000")
0
 
LVL 3

Expert Comment

by:wpsjr1
ID: 6152655
Dim i As Long
i = 1
Debug.Print Right$("00" & CStr(i), 3)
0
 

Author Comment

by:vannwms
ID: 6152656
Thank you for the formating information, but I want to reset the tracking number to 001 on the first of the year.

Your assistance is appreciated.

vannwms
0
 
LVL 4

Expert Comment

by:PBuck
ID: 6152665
I would suggest having a procedure that checks for first day of year (Julian date of 0 as an example).  Place this code within your form_load event or some where similiar where it will be ran somewhere up front.

To top it off, place some sort of key value within your registry or INI file that flags that you have done this for the current year.  This way, if your user gets on the for the first time this year on Jan 3 - your flag for the current year should be false - set the flag to true and change the counter to 001.

Hope this helps some.
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6152715
Hi, Create a small program to read the value of current number (from registry/ files/ database?), let the program run at Startup/ Windows boot, or set in registry:

(Create a string value in HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run)


Just let the program read from the source from Starting windows, determine the value, if value Not equally to 0 and date = diedline (first day of the year), set it to 0, save a string/ key to stop detecting next time, or remove the string in Startup/ Windows boot, or set in registry.

Hope this give you an idea..
0
 
LVL 4

Expert Comment

by:PBuck
ID: 6152744
Remember you need to take into consideration whether or not people will be starting this application on the first day of every year.  Will the Julian date 0 be on a Saturday when nobody works - or is this program a batch type application?
0
 
LVL 3

Expert Comment

by:wpsjr1
ID: 6153545
Store the year to a registry key on initial installation.  Then each time the application is run check the current year. If it is not the same as the stored year then reset the tracking number.

Private Sub Form_Load()
  Dim sCurrentYear As String
 
  sCurrentYear = Year(Now)
  If GetSetting("app", "sec", "curryear", "") <> sCurrentYear Then
    If MsgBox("Reset tracking numbers?", vbOKCancel Or vbQuestion) = vbOK Then
      SaveSetting "app", "sec", "tracking", "001"
      SaveSetting "app", "sec", "curryear", sCurrentYear
    End If
  End If
End Sub

' or appropriate code to save tracking to the DB instead of SaveSetting.
0
 

Author Comment

by:vannwms
ID: 6216028
Reset the tracking number was my biggest problem, but since none of the other ideas worked, I did use your solution for my formating problem.

Thanks Rod

vannwms
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now