?
Solved

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

Posted on 2001-06-04
8
Medium Priority
?
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 3

Accepted Solution

by:
RodStephens earned 200 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
LVL 53

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

765 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