Jump to content

Serializing a set of records


This topic is 7866 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need to SET a group of records on field TYPESEQ. Once set, this field TYPESEQ (text) will be an auto-enter (calc) using a global & 2-digit sequential number so new records are auto-assigned and the sequential number portion will increase by 1. But I'm a bit confused on how to indicate +1 through a series of records in this SET script first, to bring my existing records up to speed. What I currently have is:

gType & Right("00" & 01,2) > is this how I list it if I want to begin with 01?

But then, how do I indicate that I want to increase only the NUMBER portion by 1 for the next record? Use Right again? It looks like I should do this in two steps and COMBINE the results to set each field (gType & (number result). If I had the 'number' portion separate, I could use PreviousRecord(number)+1. If I tried to use PreviousRecord(TypeSeq + 1) it would also grab the global. crazy.gif I hope this is making sense; maybe I also need to loop (which I've never done). Again, for the millionth time, I call upon the forum to help me determine the proper scripting sequence. And, I really AM beginning to learn this stuff but not nearly quick enough to suit me smirk.gif

Link to comment
Share on other sites

First create a serial number field called 'Serial' with the 'auto-enter serial' option enabled, then reference that in your calc. Viz:

gType & Right("00" & Serial, 2)

This will work but, of course, will only be valid for numbers up to 99 wink.gif

Link to comment
Share on other sites

Oh, that's MUCH easier ... thanks, Ray! Yes, the number will max out at 24 so it's not a worry. And since, once created, the new number field SERIAL will 'take care of itself' by incrementing, I can just insert the FIELD Serial in the formula - gType & Right("00" & Serial,2)

I'll still have to learn loops, but that will come later. Any old DOS folks out there? Loop appears to be the same principle as GOTO labels. grin.gif

Link to comment
Share on other sites

Well, for goodness sakes! "Using REPLACE, serial number option and with the "Update Serial Number in Entry Options" feature enabled" is certainly easier than having to write a SET script! AND, it was much faster than SETting through the entire db also! I like REPLACE! smirk.gif

Link to comment
Share on other sites

I used to like Replace, but it's dangerous in multi-user installations.

If another user is editing a record when you use Replace, that record will be skipped. You can detect that with an If[status(CurrentError)=301] though.

However, here is the scary part. If you have two users running a script that uses Replace on the same field in the same set of records, or an overlapping set of records, it is possible for one user to overwrite the other user's values with no error being generated at all. In fact, if you have two users on two computers with different processing speeds, it's actually possible for both users to overwrite some of each other records at the same time with no error generated. The only time that an error code seems to be generated is when the replace functions on both computers happen to hit the same record at exactly the same time (and even then I'm not sure you would get an error).

So beware of putting Replace in a script that may be run by multiple users.

Link to comment
Share on other sites

Thanks for that Bob! I'll also add that to my networking piece. This is for a data migration project and is being manually executed on a stand-alone system. I will keep that in mind for a multi-user environment, particularly if used in scripts! It DOES work great for some things, though, doesn't it!

Link to comment
Share on other sites

This topic is 7866 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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