Solved

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

Posted on 2001-06-04
8
152 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change vba from autofit to 13.5 width? 4 28
Adding to a VBA? 6 61
Protecting vb6 & .Net code Obfuscation 18 94
how to know if my Checkbox is True in VB6.0? 9 38
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 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

18 Experts available now in Live!

Get 1:1 Help Now