Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2001-06-04
8
Medium Priority
?
161 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

618 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