Normal Topic FormRunProgram ( ), what am I doing wrong? (Read 1059 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
FormRunProgram ( ), what am I doing wrong?
Apr 14th, 2008 at 3:33am
Print Post Print Post  
I am trying to run a Code attached to a different form.

Code
Select All
var vTmp as Int
	vTmp = @SelectTreeItem(@Application + "!Forms!Search/Update!Physical!Physical")

FormRunProgram ("Physical", "Select_Dates" , Program_Event_LE_Enter)
 



The code attached to the the "Select_Dates" command button element is as follows:

Code
Select All
var vResult as String
var vString as String
var vStr as string


vResult = @FormAsDialog ("DialogDates")

WriteLn (vResult)

vResult = @Replace (vResult, "=", ";")
vResult = @AccessStringArray (vResult, 2) + ";" +
	  @AccessStringArray (vResult, 4)

WriteLn (vResult)


//vResult = "2008/02/17;2008/02/28"

vString =  "{Date1 >= " + @chr (34) +  @AccessStringArray(vResult, 1)  + @Chr (34) + " and " + "Date1 <= "  + @chr (34) + @AccessStringArray (vResult, 2) + @Chr (34) + "}"
//WriteLn (vString)
// {Date1 >= "2008/02/17" and Date1 <= "2008/02/28"}

His1 = vString

vStr = @SpecCommand (2, 1, "")
 



What I expecting was to open the DialogDates form and picks up the dates and then Run the retrieve spec.  When I press the command button "Select_Dates" in the "physical" form, everything works fine as it is supposed to but it is not activating the code with FormRunProgram ( ) from other form. What am I doing wrong?

Moreover the Programing Guide states that the form name can be specified with the Mode Specifier. Is it using if @Mode () = 2 then command or by some other method?
  
Back to top
 
IP Logged
 
Ben
Lantica Support
*****
Offline



Posts: 218
Joined: Apr 7th, 2005
Re: FormRunProgram ( ), what am I doing wrong?
Reply #1 - Apr 14th, 2008 at 3:33pm
Print Post Print Post  
FormRunProgram() may be running before the specified form has a chance to run. Try using Loiter() to give it a chance to load:
[code]
var vTmp as Int
vTmp = @SelectTreeItem(@Application + "!Forms!Search/Update!Physical!Physical")
Loiter(2000)
FormRunProgram ("Physical", "Select_Dates" , Program_Event_LE_Enter)[/code]

[quote]Moreover the Programing Guide states that the form name can be specified with the Mode Specifier. [/quote]

The mode specifiers are the same as those used for @FormFieldValue()

[b]EXAMPLE:[/b]
[code]var vString as string
vString = @FormFieldValue("Countries!Cities:(add)", "Population", 1)[/code]
The mode specifier is  ':(add)' in this example.

You can also use :(update) or :(search)

  
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunProgram ( ), what am I doing wrong?
Reply #2 - Apr 14th, 2008 at 3:48pm
Print Post Print Post  
[quote]
The mode specifier is  ':(add)' in this example.
You can also use :(update) or :(search)
[/quote]

Thanks.

[quote]
FormRunProgram() may be running before the specified form has a chance to run. Try using Loiter() to give it a chance to load:
[/quote]

I even placed a second command button besides the first one that opens up the form with SelectTreeItem ( ) command to avoid the above. Still noting doing.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: FormRunProgram ( ), what am I doing wrong?
Reply #3 - Apr 14th, 2008 at 4:15pm
Print Post Print Post  
Bharat,

Normally, the Physical form would run it's own code, as it knows when it is able to do so. Is there a reason why you are not doing so?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunProgram ( ), what am I doing wrong?
Reply #4 - Apr 14th, 2008 at 5:53pm
Print Post Print Post  
Yes, I want to have my help to print out the data without much exposure to that file, such as opening the file and pressing command button, etc. Less exposure the better.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: FormRunProgram ( ), what am I doing wrong?
Reply #5 - Apr 14th, 2008 at 8:32pm
Print Post Print Post  
Bharat_Naik wrote on Apr 14th, 2008 at 5:53pm:
Yes, I want to have my help to print out the data without much exposure to that file, such as opening the file and pressing command button, etc. Less exposure the better.


Can you make use of On Form Entry to do what you need to do as soon as the form opens? Perhaps in combination with @FormAs Dialog or suchlike?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunProgram ( ), what am I doing wrong?
Reply #6 - Apr 14th, 2008 at 9:05pm
Print Post Print Post  
That will do. Ideally I was thinking of having a button on Main Menu panel and that will open up FormAsDialog and take input of FromDate and TODate and that should print out the data and close the form.  Thanks.

  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: FormRunProgram ( ), what am I doing wrong?
Reply #7 - Apr 14th, 2008 at 9:43pm
Print Post Print Post  
Have you considered @Calendar? It's pretty good for selecting dates.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: FormRunProgram ( ), what am I doing wrong?
Reply #8 - Apr 14th, 2008 at 9:46pm
Print Post Print Post  
Yes, I always place them by the date element and my employees love them.
  
Back to top
 
IP Logged