Normal Topic Adding "control numbers" to records (Read 1224 times)
Bill A.
Member
*
Offline



Posts: 5
Joined: Jun 30th, 2014
Adding "control numbers" to records
Jun 30th, 2014 at 4:34pm
Print Post Print Post  
I have an existing data file I need to add a number to for each record in the file.  I have added a "ControlNo" element to the form.

Is it possible to do this via "Mass Update" by writing a simple formula in the Update Spec?  If so, what would that formula look like?

I'd like to simply start with the number "1" and have it count up sequentially to nearly 400,000.

  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Adding "control numbers" to records
Reply #1 - Jun 30th, 2014 at 4:50pm
Print Post Print Post  
Hello Bill,

Yes, this is possible to do with a Mass Update spec. The programming would look similar to the following.

Code
Select All
Var vControlNumber as Int

vControlNumber = @ToNumber(@GlobalValue("ControlNumber")) + 1
ControlNo = vControlNumber
GlobalValue("ControlNumber", vControlNumber) 



This code is using a GlobalValue to keep track of the last number assigned. so what you can do in programming is use that same GlobalValue to assign a ControlNo to a new record as it is added.

-Ray
« Last Edit: Jul 3rd, 2014 at 1:14pm by Ray the Reaper »  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bill A.
Member
*
Offline



Posts: 5
Joined: Jun 30th, 2014
Re: Adding "control numbers" to records
Reply #2 - Jul 3rd, 2014 at 1:43am
Print Post Print Post  
Thank you, Ray.

I'm a bit confused about doing this with a retrieve spec.  The nearly 400,000 records are already in the database so will your suggestion work any way?

And the element name is "ControlNo", so shouldn't that be what I'd use throughout the formula?  Or, does the "ControlNo = vControlNumber" part of the formula take care of that issue?
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Adding "control numbers" to records
Reply #3 - Jul 3rd, 2014 at 1:16pm
Print Post Print Post  
Hello Bill,

I apologize. I meant Mass Update spec not Retrieve spec. I've edited my original post so as to avoid confusion in the future.

Yes the line ControlNo = vControlNumber is the line that sets the number back to the actual element.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Bill A.
Member
*
Offline



Posts: 5
Joined: Jun 30th, 2014
Re: Adding "control numbers" to records
Reply #4 - Jul 4th, 2014 at 3:06pm
Print Post Print Post  
Thanks again, Ray.

I will give this a try and let you know how it goes.

  
Back to top
 
IP Logged
 
Bill A.
Member
*
Offline



Posts: 5
Joined: Jun 30th, 2014
Re: Adding "control numbers" to records
Reply #5 - Jul 4th, 2014 at 7:37pm
Print Post Print Post  
Ray...
I'm not having any success with this code.

I'm setting up a retrieve request that asks for all records with nothing in the ControlNo element.  Then I set up a Mass Update spec using the code you've given me.  When I try to run the spec I get the message "Some or all of this mass update has failed to compile.  It will not execute".

I'm going to try and attach a screen shot of the Program Editor "Error String" message so you can see it.
  

Program_Editor_Error_String.JPG ( 50 KB | 47 Downloads )
Program_Editor_Error_String.JPG
Back to top
 
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Adding "control numbers" to records
Reply #6 - Jul 4th, 2014 at 9:07pm
Print Post Print Post  
Hi Bill,

Try running your Mass Update code in any element other than Global Code, it should work just fine.

Brandon
  
Back to top
IP Logged
 
Bill A.
Member
*
Offline



Posts: 5
Joined: Jun 30th, 2014
Re: Adding "control numbers" to records
Reply #7 - Jul 8th, 2014 at 8:55pm
Print Post Print Post  
OK, I'll give that a try and see what happens.
  
Back to top
 
IP Logged