Hot Topic (More than 10 Replies) Has not been committed to the database (Read 1383 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Has not been committed to the database
Dec 24th, 2010 at 2:12pm
Print Post Print Post  
The code below works except that when you try to go back to search mode or to close tab, the "The current record has been changed and has not been committed to the database. Are you sure you want to close this record?" warning pops up. If you click yes twice, the record is retained but without a "unique" number that the record was given when you entered add data mode, and before performing the import. If you manually select Save Record it works just fine and retains the unique number.

Can you help me save this record with programming?

Thanks for the help.

Code
Select All
var vRun as Int
var vSpec as String
var vFile as String

	vSpec = "ImportRefRecord"
	vFile = "C:\Sesame2\Docs\ExportRef.txt"
	vRun = @LoadImportSpec(vSpec)
	If vRun = 1
	{
		If FileExists(vFile)
		{
			RunImportSpec(vFile)
		}
		Else
		{
			@Msg("Could not find the import file " + vFile)
		}
	}
	Else
	{
		@Msg("Could not find the Import spec named " + vSpec)
	}

Formcommit("Ledger") //Save subform
Formcommit("Reference") //Save parent
 

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Has not been committed to the database
Reply #1 - Dec 24th, 2010 at 2:51pm
Print Post Print Post  
Hello Brandon,

I have a theory. Try the following code and let me know if it works.

Code
Select All
var vRun as Int
var vSpec as String
var vFile as String

	vSpec = "ImportRefRecord"
	vFile = "C:\Sesame2\Docs\ExportRef.txt"
	vRun = @LoadImportSpec(vSpec)
	If vRun = 1
	{
		If FileExists(vFile)
		{
			RunImportSpec(vFile)
		}
		Else
		{
			@Msg("Could not find the import file " + vFile)
		}
	}
	Else
	{
		@Msg("Could not find the Import spec named " + vSpec)
	}

Formcommit("Ledger") //Save subform
Formcommit("") //Save parent 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #2 - Dec 24th, 2010 at 3:35pm
Print Post Print Post  
Hi Ray,

No change.
  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #3 - Dec 24th, 2010 at 3:44pm
Print Post Print Post  
I don't know if this helps you diagnose this or not, but I have found that after I do the import I have to click on an LE in the parent in order for the manual Save Record to take effect. I didn't think that that's what I had been doing before, and why I said that the manual Save Record worked in my original post.
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Has not been committed to the database
Reply #4 - Dec 24th, 2010 at 3:48pm
Print Post Print Post  
Let me build a Test case here and see what I can find out for you.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #5 - Dec 24th, 2010 at 3:51pm
Print Post Print Post  
Thank you very much Ray!
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Has not been committed to the database
Reply #6 - Dec 24th, 2010 at 3:58pm
Print Post Print Post  
It looks like your Unique Number is being assigned after the import, which thinking about it makes sense now. This means that the imported record has already been saved by your import routine and then changed by the On Form Entry routine. To fix this you can place this code in global

Code
Select All
Stat gsSave as Int

gsSave = 0 



Add this code to the bottom of your OnFormEntry Event

Code
Select All
If gsSave = 1 Then
{
	FormCommit("")
	gsSave = 0
} 




and this code to your import button right after the RunImportSpec(vFile) line
Code
Select All
gsSave = 1 



-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #7 - Dec 24th, 2010 at 4:05pm
Print Post Print Post  
You are a genius!

Works great, can't thank you enough!

Brandon
  
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #8 - Dec 24th, 2010 at 4:21pm
Print Post Print Post  
Hi Ray,

So, in theory should this code work to perform all the tasks of exporting and then importing all at one time?

I can't get it to work, or, am I asking for too much here?

Code
Select All
var vNav as Int
var vExp as Int
var vSpec as String
var vFile as String
var vRun as Int

	vExp = @LoadExportSpec("ExportRefRecord")
	If vExp = 1
	{
		RunExportSpec("Docs\ExportRef.txt",",","",0,1,0,1,0,1,0,0)
	}

vNav = @SelectTreeItem("Search Update Menu!Navigation!Switch to Add Data Mode (Ctrl-F6)")

@exit

	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)
	}

Formcommit("Ledger") //Save subform
Formcommit("") //Save parent  

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Has not been committed to the database
Reply #9 - Dec 24th, 2010 at 4:34pm
Print Post Print Post  
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

Code
Select All
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

Code
Select All
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
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Has not been committed to the database
Reply #10 - Dec 24th, 2010 at 4:44pm
Print Post Print Post  
What ever you do, don't lose the "top of your head"! I need it!

Works great, thank you very much, again!

  
Back to top
IP Logged