Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Reset serial# monthly

Featured Replies

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.

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

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

  • Author

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

  • Author

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?

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

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.