For starters, you should avoid using macros if possible. You can do almost anything in Sesame with programming. In all the things I've done with Sesame, I only use macros for one specific purpose which can't be programmed, and even then I write the macro in code on-the-fly, then write it to disk just before calling it.
You need to use a ClientLocalValue as a flag before opening another form, so that once the other form opens, you can check for the state of that ClientLocalValue with a conditional statement.
Here's a rough example of this technique.
This is code from a command button on my Main Menu form:
var vNav as Int
If (@FormResultSetTotal("Invoice:(Add)") = -1) and (@FormResultSetTotal("Invoice:(Search)") = -1) and (@FormResultSetTotal("Invoice:(Update)") = -1)
{
ClientLocalValue("Billables", 1)
vNav = @SelectTreeItem(@Application + "!Forms!Search/Update!Invoice!Invoice")
}
Else
@MsgBox("All the Invoice tabs must be closed to view Billables.", "", "Close the tabs, and select Billables again.")
This is code in the Invoice :: On Retrieve Spec Open event:
// Reset the flag if previous run did not find any records to retrieve and left the flag set,
// because the flag normally doesn't get reset until the "Invoice :: On Form Entry" event.
if @ClientLocalValue("Billables") = 2
ClientLocalValue("Billables", 0)
if @ClientLocalValue("Billables") = 1
{
ClientLocalValue("Billables", 2)
vNav = @LoadRetrieveSpec("Billables")
vNav = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
}
This is code in the Invoice :: On Form Entry:
if @ClientLocalValue("Billables") = 2 and @Update
{
ClientLocalValue("Billables", 0)
// Load and run specs, etc.
}