Skip to main content

Script to pass the prompt for first time control total calculation

Hello!
When using IDEAscript to run a macro to calculate the control total on a specific field, IDEA will prompt the user to accept calculating for the first time. Is there a way to bypass this using a script?
Thank you!
Shawn

Brian Element Wed, 12/23/2015 - 07:33

Hi Shawn, yes there is.  Unfotunately I just switched jobs and I am still waiting for them to install IDEA on my work computer so I can't look up the exact command.  If you go into the help that has all the IDEAScript commands look under fieldstats, there is example code that will check to see if the fieldstats have been generated and if they haven't been generate then there is a command to force the generation of the stats.  This will get rid of the user prompt to calculate the field stats.

PATKELL Thu, 07/26/2018 - 14:53

I tried to find these command but could not.
I creating a macro that inserts a field that uses the field stats function but the field returns ERROR as the fields stats need to be run first.
 
what cmmand do i inset beofre the creation of the field( and equations) that ensure the fieldstats are run. I  am doing a number of extractiosn and then creating the fields in each extraction >
 
thanks
 
pat
 
 
 

Brian Element Thu, 07/26/2018 - 16:55

Hi Pat,

 Here is some example code.  You first access the field you want the stats on, in this case the CREDIT_LIM file and then test to see if the stats have been computed and if it hasn't then compute it.

Brian


Sub Main

	' Open the database.
	Set db = Client.OpenDatabase("Sample-Customers.IMD")
	
	' Get the field statistics.
	Set stats = db.FieldStats("CREDIT_LIM")
	
	' Determines whether the field statistics have been computed.
	If stats.Computed Then
		MsgBox "The statistics are already computed." 
	Else 
		MsgBox "Computing the statistics." 
		stats.ComputeStats
	End If 
	' Clear the memory.
	Set db = Nothing
	Set stats = Nothing

End Sub 

Robert van den… Tue, 09/04/2018 - 06:07

is there a script to calculate all field stats at once? the way IDEA does it when you click Field Statistics.

Brian Element Tue, 09/04/2018 - 10:24

In reply to by Robert van den…

I believe IDEA computes all stats at once.  So you are checking one field to see if it is computer, when you force the script to compute the stats I believe it does it for all the fields.