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:
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("")