Normal Topic FormRunProgram help (Read 467 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
FormRunProgram help
Nov 5th, 2011 at 5:32pm
Print Post Print Post  
I have two forms; Invoice and Customers. The Customers form contains a subform called Ledger.

I’m trying to run FormRunProgram from the Post button on the Invoice Form.

I want it to run the InvPost :: On Form Entry code on the Customers form. InvPost posts data from the Customers parent to the Ledger subform.

What I’m trying to accomplish is; I want to be able to enter one invoice after the other, for the same customer, and have a new record created in the Ledger for each invoices data.

I can’t find a way to make it work. I do have the Customers database open when running and am using #include "Sbasic_include.sbas".  On its own, running the Invpost code when opening Customers, works fine.

Am I missing something simple?

** EDIT ** Completely forgot about XResultSetCreateNewRecord & XResultSetValue, so the problem is solved with posting to the Ledger. However, still would like to know what I'm missing with FormRunProgram.

Thanks.

Here’s the code:
Code
Select All
INVOICE FORM

Post :: On Element Entry

FormCommit("Invoice")

			XPost(@fn, AcctNumInv, "Customers!AcctNum", "1", "InvPost", "")
			XPost(@fn, AcctNumInv, "Customers!AcctNum", InvoiceDate, "InvoiceDate", "")
			XPost(@fn, AcctNumInv, "Customers!AcctNum", Invoice number, "Invoice number", "")
			XPost(@fn, AcctNumInv, "Customers!AcctNum", Total, "Charges", "")

			FormRunProgram("Customers", "InvPost",PROGRAM_EVENT_FORM_ENTER)


ON THE CUSTOMERS DATABASE

Invpost :: On Form Entry

If Invpost = "1" then
{
			If @FormFieldValue("Ledger", "InvoiceDate", 1) <> ""  or @FormFieldValue("Ledger", "Invoice Number", 1) <> "" Then
			{
				nn = @FormNewRecord("Ledger")
			}
			Else
			{
				nn = 1
			}

		FormFieldValue("Ledger", "InvoiceDate", nn, InvoiceDate) 
		FormFieldValue("Ledger", "Invoice Number", nn, Invoice Number)
		FormFieldValue("Ledger", "Description", nn, Description)
		FormFieldValue("Ledger", "Charges", nn, Charges)

		FormCommit("Ledger")
		FormCommit("")
	 

« Last Edit: Nov 5th, 2011 at 8:11pm by tcgeo »  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: FormRunProgram help
Reply #1 - Nov 7th, 2011 at 5:12pm
Print Post Print Post  
I'm not sure why it isn't working for you. Is there any reason you are not placing the called code in a subroutine and simply calling that subroutine from the "Post:: On Element Entry" routine and from the On Entry routine of "Invpost"?

If you want to continue debugging this, try placing a much simpler routine in the called code - something completely non-conditional and very visible, just to see if the code is executing. If it is, check you conditions carefully. If it isn't, we'll try a super-simplified example here.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: FormRunProgram help
Reply #2 - Nov 7th, 2011 at 7:53pm
Print Post Print Post  
Hello Mark,

Thank you for looking into this. I don't have an answer for you on why I don't have it in a subroutine, etc. But I originally did have the Invpost firing on the Customers On Form Entry and it worked fine.

To try to get FormRunProgram figured out, and in case something else was effecting this, I built one new LE on the Customers database to post to. The data from the invoice posts fine to that LE. I also built a new command button for the FormFieldValue code. I have it firing on On Element Change base upon someone elses suggestion. I've also put it into an LE on the customers form using On Element Entry, all with no luck.

If I put the FormFieldValue code into the new command button on On Element Entry and click on it, it works just fine for posting to the subform ledger.

So, I'll take you up on the "super-simplified example" if you don't mind.

I appreciate it, thank you

  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: FormRunProgram help
Reply #3 - Nov 7th, 2011 at 8:30pm
Print Post Print Post  
I just built a simple example in Countries.db that calls the event code attached to the City element, both on element entry and on form entry. Both worked well.

Double check your form name, element name, etc... Comment out the code and replace it with a simple Writeln, just to make sure its getting called.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged