Saubs Posted August 22, 2006 Posted August 22, 2006 The first time a particular script is executed each month, I want the serial number in to revert to 01. Not sure the best way to do this, any suggestions greatly appreciated. (Am in the process of rebuilding our databases to FM8, but in the meantime gotta get this working in FM6) Thanks very much.
wolfe Posted August 23, 2006 Posted August 23, 2006 Try this old file to get you started. I used a variation of this to create autoenter serials that begin anew at the beginning of each year. SerCat.zip
T-Square Posted August 24, 2006 Posted August 24, 2006 Of course, the first question I would ask is: why reset the serial number each month? Most usually, such actions imply a need that is being met through a less-than-ideal solution. For example, people want to know how many orders have been made this month (or by this client, or for this salesman, etc.), which can be better managed and determined using relationships and calculated fields. But if you really want to reset the value each month, try: If[_gMonth <> Month(Get(CurrentDate))] # The IF tests whether the reset has taken place this month Set Next Serial Value [myfield; "1"] Set Field[_gMonth = Month(Get(CurrentDate)) End If David
Saubs Posted August 25, 2006 Author Posted August 25, 2006 Thanks for your replies, folks. To answer your question, T-Square, it's a YYMM## 'Job Number' calculated field that needs to reset each month. Was having a tough time getting the trailing ## (serial) digits to behave. Thanks again-- Cheers
Saubs Posted August 29, 2006 Author Posted August 29, 2006 T-Square-- One thing I'm concerned about with your suggestion: won't the data in the global field _gMonth go away each time the file gets closed? Because data in globals don't get saved?
T-Square Posted August 29, 2006 Posted August 29, 2006 Well, Emo, the answer on whether globals persist is that "it depends." In a typical standalone situation, globals persist from session to session. Howver, according to FM help: "If your file is shared, only the host's changes to global field data are saved. Changes are saved only when the file is closed." So, you're right if you're hosting the file on a server and it doesn't get closed. But otherwise, it should be fine. I'm not sure where you got the idea that globals don't get saved. But you don't really answer why you need this. David
Recommended Posts
This topic is 6663 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now