Normal Topic RunExportSpec and Subform records (Read 1730 times)
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
RunExportSpec and Subform records
Feb 11th, 2008 at 10:34pm
Print Post Print Post  
Hello!
running a RunExportSpec , is there a way to export the Subform records with the Main form records together ?
i want the export file with a semicolon as separater and " as delimeter.

i try to use this code in the main form:

var vRun as Int
vRun = @LoadExportSpec("Patients")
If vRun = 1
{
RunExportSpec("c:\Sesame2\Data\ExpPat.txt",";","",0,1,0,1,0,1,1,1)
}

// RunExportSpec(filename, separator, delimiter, tabbed, custom_sep, no_sep,ignore_fixed,
// all, none, ustom_delimiter, header)

Thanks.
Dr. Belhareth
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re:  RunExportSpec and Subform records
Reply #1 - Feb 12th, 2008 at 3:13am
Print Post Print Post  
Quote:
is there a way to export the Subform records with the Main form records together ?

When building the export spec for the main form, you should see the subform elements listed the spec window. For example, if you had a subform named "Transactions" and it had a field named "InvDate", you should see "Transactions!InvDate" in the list of available choices in the spec window.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re:  RunExportSpec and Subform records
Reply #2 - Feb 14th, 2008 at 1:26pm
Print Post Print Post  
Hallo Carl,

Thank you very much.

I have another question: can i use the runExportSpec starting with a command button  from outside the file that  data should deliver?

Thanks.
Dr. Belhareth

  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re:  RunExportSpec and Subform records
Reply #3 - Feb 14th, 2008 at 3:07pm
Print Post Print Post  
When you say "outside the file", do you mean outside of the application; or outside of the database, but still in the same application?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re:  RunExportSpec and Subform records
Reply #4 - Feb 14th, 2008 at 11:24pm
Print Post Print Post  
Hello Carl,

I mean outside the Form but  in another Form in the same Application .

Thanks


  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1350
Location: New Hampshire
Joined: Mar 11th, 2003
Re:  RunExportSpec and Subform records
Reply #5 - Feb 15th, 2008 at 11:20pm
Print Post Print Post  
Yes, you can.

One way, would be to make use of @SelectTreeItem, ClientLocalValue, @LoadExportSpec, and RunExportSpec. (Or, the new @SpecCommand can perform many of the spec related functions.)

Basically, the command button would contain something like:
Code
Select All
var n as int

ClientLocalValue("RunMyExport", 1)
n = @SelectTreeItem(@Application + "!Forms!Search/Update!MyDB!MyForm") 


This sets a global value locally (ClientLocalValue) that will be used as a conditional in the other form. Then, @SelectTreeItem opens the form you want to export from.


In the target form's On Retrieve Open Spec event:
Code
Select All
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("RunMyExport") = 2 then ClientLocalValue("RunMyExport", 0)

If @ClientLocalValue("RunMyExport") = 1
{
	ClientLocalValue("RunMyExport", 2)
	n = @LoadRetrieveSpec("Records to Export")  //This can be left out if you want to export all records
	n = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")
} 




In the form's On Form Entry event:
Code
Select All
var vRun as int

If @ClientLocalValue("RunMyExport") = 2 and @Update
{
	ClientLocalValue("RunMyExport", 0)
	vRun = @LoadExportSpec("Patients")
	If vRun = 1
	{
		RunExportSpec("c:\Sesame2\Data\ExpPat.txt",";","",0,1,0,1,0,1,1,1)
	}
	@Exit
	Stop	//@Exit doesn't stop code in version 2, it lets the rest of the event execute.
} 


You can remove the @Exit and Stop commands if you want to be left looking at the result set when the export is done; or you can leave them there to exit out of the form after the export is done.


There's always more you can include, but that should get you going in the right direction.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged