obfusc88 wrote on Feb 17
th, 2008 at 12:35am:
2. I can put that code into the PO form but what do I put into the PO Lines to let me click down to add a new poline, but not let met click down three times and add three records?
If you want to
never allow more than two line items in the subform, then you could do it this way.
You would put this in the form's On Form Entry event
and the On Element Immediate Change event:
If @ResultSetTotal() = 2
NotifyForm(7)
Else
NotifyForm(-7)
Quote:3. Ok so you agree how to do this. but want i need is some code to show how to make that happen. The PO Lines are on a subform on a PO tab. So I need to see sample program for button to Open PO Line Form in Table view, only show records that have status=open, sorted by due date. Then How do I select one of the lines and make the PO form open and got to the tab for the line items and go to the line item? I cannot put a button on the table view, so what can i do to make the selcetion and run the code i need to see to do that?
I wouldn't open the "Line Form" (subform), but rather the
main PO form in Table View. From there you could put focus on a line, and the click on the button (new in 2.0.5) at the top left corner of the corner of the Table View to bring you back to the Form View of the main form. Then you can add or edit the subform line items.
You would put this in a command button on the menu form:
var n as int
ClientLocalValue("ShowOpenPOs", 1)
n = @SelectTreeItem(@Application + "!Forms!Search/Update!MyDB!MyForm")
In the target form's On Retrieve Open Spec event:
var n as int
// Resets the flag if previous run did not find any records to retrieve and left a flag set,
// because the flag normally doesn't get reset until the "On Form Entry" event.
If @ClientLocalValue("ShowOpenPOs") = 2 then ClientLocalValue("ShowOpenPOs", 0)
If @ClientLocalValue("ShowOpenPOs") = 1
{
ClientLocalValue("ShowOpenPOs", 2)
n = @LoadRetrieveSpec("MyRetrieveSpec")
n = @LoadSortSpec("MySortSpec")
n = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
In the form's On Form Entry event:
var n as int
If @ClientLocalValue("ShowOpenPOs") = 2 and @Update
{
ClientLocalValue("ShowOpenPOs", 0)
n = @SelectTreeItem("Search Update Menu!Other Commands!Toggle Table View (Shift-F6)")
}
You'll need to create and save some retrieve and sort specs for use with this, then replace "MyRetrieveSpes" and "MySortSpecs" with the names you saved them as.