No code after an @Exit will run. You'll need to split the code into two sections. One to export and open Add mode and the second one to run the import after add is opened. Off the top of my head the following should work for you.
Try this in your buttons event
var vNav as Int
var vExp as Int
vExp = @LoadExportSpec("ExportRefRecord")
If vExp = 1
{
RunExportSpec("Docs\ExportRef.txt",",","",0,1,0,1,0,1,0,0)
}
ClientLocalValue("ImportRoutine", 1)
vNav = @SelectTreeItem("Search Update Menu!Navigation!Switch to Add Data Mode (Ctrl-F6)")
@Exit
Then in your On Form Entry Event add
var vSpec as String
var vFile as String
var vRun as Int
If @ClientLocalValue("ImportRoutine") = 1 Then
{
ClientLocalValue("ImportRoutine", 0)
vSpec = "ImportRefRecord"
vFile = "C:\Sesame2\Docs\ExportRef.txt"
vRun = @LoadImportSpec(vSpec)
If vRun = 1
{
If FileExists(vFile)
{
RunImportSpec(vFile)
gsSave = 1
}
Else
{
@Msg("Could not find the import file " + vFile)
}
}
Else
{
@Msg("Could not find the Import spec named " + vSpec)
}
}
-Ray