Normal Topic formrunprogram( ) help needed (Read 769 times)
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
formrunprogram( ) help needed
Dec 7th, 2007 at 7:57pm
Print Post Print Post  
I am trying to use formrunprogram("invoice","calc",PROGRAM_EVENT_LE_ENTER) on event exit of a subform element to run a calc button on event enter programming. (I do have #include "sbasic_include.sbas")

Basically I have a line items subform on an Invoice form. When the user exits the qty element I want the line to total but I also wanted the entire invoice to update the totals. I have a command button named Calc with a label of Calc Inv on the invoice form that when pressed runs a SubRoutine CalculateInv().  I was thinking that the formrunprogram( ) command would do the same as the user pressing the Calc button.

Am I not using this command correctly?

This is the on exit logic I am using.

//This Code calculates the total cost of the line item

Var vQty as Int

vQty = @TN(Qty)

If vQty > 0 Then
{
     Total = @TM(vQty * Price)
     ReadOnly(Total, 1)
formrunprogram("invoice","calc",PROGRAM_EVENT_LE_ENTER)
}


Issue2

While I am on subform questions I am trying to get the cursor to the first element in the line item element line on the subform . When I add an additional line to the line item subform either with F10 or
//new record
var nc as int
nc = @FormNewRecord("lineitems")

the cursor goes to the line above or the entire column (top to bottom) becomes highlighted. I have tried this
//new record
var nc as int

nc = @FormNewRecord("lineitems")

FormThrowFocus("lineitems", "prodid")

But it does not help. Do you all have any thoughts what I am doing incorrectly?

Thanks
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: formrunprogram( ) help needed
Reply #1 - Dec 8th, 2007 at 3:24am
Print Post Print Post  
I use the following code in my invoice transactions subform. I found that the subform needs to be committed before running the calculation code.
Code
Select All
If @Modified and @FormIsStandalone() = 0
	{
	FormCommit(@Layout)
	FormRunProgram(sParentFormName, "Calculate", 0)
	} 


I suppose that we both could be using FormDependentValue() instead, but I just haven't gotten around to it yet.


Issue 2:
ThrowFocus() does not work well in table view subforms in version 2. Look into using QuickMacro() to move the cursor around the table view subform. See page 4 in this month's issue of Inside Sesame (Dec 2007).

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: formrunprogram( ) help needed
Reply #2 - Dec 8th, 2007 at 5:28am
Print Post Print Post  
Carl,

Thanks for the input.  The problem is with FormRunProgram( ) and Sbasic attached to a command button element. The FormRunProgram() works fine when the code is attached to a regular element. I ran into this back in August. (I found my same post in a search. At least I am consistent.)
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: formrunprogram( ) help needed
Reply #3 - Dec 8th, 2007 at 8:28pm
Print Post Print Post  
I'm not clear on what the problem is. Mine is also running code attached to a command button, and it works.

EDIT: Correction... it's not working. See my follow-up post below.
« Last Edit: Dec 10th, 2007 at 4:50am by Carl Underwood »  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: formrunprogram( ) help needed
Reply #4 - Dec 9th, 2007 at 6:27am
Print Post Print Post  
Carl, thats good to know that it works for you even with a command button. It must be something I am doing wrong then. I will keep working on it.

Sesame is such a great product and lets me do so much while I know so little, its frustrating when I get in my own way. Sad

Thanks for the help, it is always greatly appreciated.

Robert
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: formrunprogram( ) help needed
Reply #5 - Dec 10th, 2007 at 4:48am
Print Post Print Post  
Robert,

You're correct! It does NOT work if the target code is in a command button's On Element Entry event (I did check it in a few of the other events, and it DOES work in them).

I'm sorry I told you it worked for me. I hope I haven't caused you to much "head banging" trying to fix your code. The code attached to my command button is a subroutine that's also located in other events on the parent form. One of the other events were triggering it, and so, got the job done; leading me to believe FormRunProgram() was working.

As a workaround, you can copy the same code that is in the command button On Event Entry event, and paste it in the command button On Element Change event. Since a command button doesn't change (unless you are relabeling it or something), it shouldn't cause any harm, but will allow you to call the code using FormRunProgram("Invoice", "Calc", PROGRAM_EVENT_LE_CHANGE).

Do you want to write this up, or should I?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: formrunprogram( ) help needed
Reply #6 - Dec 10th, 2007 at 1:44pm
Print Post Print Post  
Using the ENTER event of a button is not working because buttons do not actually run their code when entered, like a text box would. This prevents a button from running code just because you tabbed through it. Therefore, when FormRunProgram() sends the ENTER event to the button, it shrugs and says it's not meant to do anything.

We tell the click on a button to run the code residing in the On Entry event under the hood.

If one of you goes ahead and writes this up, we'll decide what to do about it. At the least, we need to document this.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged