Page Index Toggle Pages: [1] 2  Send Topic Send Topic Print Print
Hot Topic (More than 10 Replies) Duplicate Record (Read 2295 times)
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Duplicate Record
Dec 21st, 2010 at 1:48pm
Print Post Print Post  
I'm using the code below to duplicate a record, it works fine except that it doesn't copy the subform data.

Is it possible to modify this code so that the subform data will be duplicated also?

Thanks.

Code
Select All
Var vCopy as Int
Var vNew as Int
Var vDupe as Int
Var vSave as Int

vCopy=@selectTreeitem("Search Update Menu!Edit Commands!Copy Form to Buffer (F11)")

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

vDupe=@selectTreeitem("Add Data Menu!Edit Commands!Paste Buffer to Form (Shift-F11)")

VSave=@selectTreeitem("Add Data Menu!Navigation!Save Record") 

  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Duplicate Record
Reply #1 - Dec 21st, 2010 at 10:47pm
Print Post Print Post  
You might want to check out this thread for a similar situation...

http://www.lantica.com/Forum3/cgi-bin/yabb2/YaBB.pl?num=1292685347/0

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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Duplicate Record
Reply #2 - Dec 22nd, 2010 at 11:24am
Print Post Print Post  
Thank you for pointing me to that post Steve_in_Texas.

Export/import works, thank you Carl.

I hope you both have a Merry Christmas!

Brandon



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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Duplicate Record
Reply #3 - Dec 23rd, 2010 at 6:16pm
Print Post Print Post  
Well, I thought I had it working...

If there is one record in the subform, calling RunExportSpec or performing a manual export, will create one record in the txt file and the import works fine. If there are two or more records in the subform, RunExportSpec, or manual export will create as many parent records as there are entries in the subform, in the txt file. All the data from the subform does get listed in the txt file. When you run an import, you get as many new records as there are subform entries, each containing one line of the subform data.

Of course, I only want one record containing all of the subform data.

I hope I was clear enough on this, any help would be appreciated, thanks.

Here's the code:

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


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


vNav = @SelectTreeItem(@Application + "!Forms!Add Data!Reference!Reference")

@exit
 

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


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Duplicate Record
Reply #4 - Dec 23rd, 2010 at 6:39pm
Print Post Print Post  
Hello Brandon,

Double check that your import spec matches the export spec. If data from one of the fields from the subform is being placed on the parent form you will get this kind of behavior.

-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: Duplicate Record
Reply #5 - Dec 23rd, 2010 at 7:34pm
Print Post Print Post  
Hi Ray,

That must have been the trouble, I couldn't see where the export didn't match the import so I started over from scratch and it works fine now, thank you.

Just curious, when looking at the txt file, is it normal for it to show as many record entries as there are subform entries?

Thanks for all of your help & have a Merry Christmas,

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


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Duplicate Record
Reply #6 - Dec 23rd, 2010 at 8:13pm
Print Post Print Post  
Hello Brandon,

Yes that is how a hierarchical export file looks like when viewed as text. You will see the parent data is the same just the subform data changes from line to line. When importing if every parent field value is the same as the last line imported Sesame knows it is the same record, so it just adds the subform data to a new child record. If even one field of parent data is different, Sesame creates a new parent record with the data from the line in it and a new child record in it. Saves that record and moves on to the next line in the import file.

-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: Duplicate Record
Reply #7 - Dec 23rd, 2010 at 8:24pm
Print Post Print Post  
Thanks for the explanation,

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


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: Duplicate Record
Reply #8 - Dec 23rd, 2010 at 8:58pm
Print Post Print Post  
You are welcome and a Merry Christmas to you too.

-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: Duplicate Record
Reply #9 - Dec 25th, 2010 at 3:22pm
Print Post Print Post  
I've continued to occasionally have further troubles with exporting and importing.  I believe I have found the culprit. One of the LE's is a text editor field. At times some of the data within this field contains a comma. When you run the export/import the comma(s) change either the export or import spec and then you get more than one copy of the original, depending on how many subform line items contain data.

I dreamed up the code below to change any commas to dashes

Code
Select All
var vNotes as string

vNotes = @Replace(Customernotes, ",", " - ")

Customernotes = vNotes

Formcommit("Ledger")

Formcommit("reference") 



which runs before this code:
Code
Select All
vRS = @FormFieldValue("reference", "Ref", 0)

vNav = @SelectTreeItem("Search Update Menu!Search (F7)")

Ref = vRs

vNav = @SelectTreeItem("Search Menu!Search Commands!Retrieve New Results (F10)")


	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 



to remove the commas first. This works OK accept that when there is also an equal "=" sign in the text field, the process stops before "Search Update Menu!Navigation!Switch to Add Data Mode (Ctrl-F6)" can take effect and lands me back to my main menu.

I'm not sure if any other characters could cause trouble with the export/import spec.

Is there a way to tell sesame to disregard any special characters within this field or any other solution?

Thanks.
  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Duplicate Record
Reply #10 - Dec 26th, 2010 at 6:26am
Print Post Print Post  
Have you tried adjusting the settings in the 'runexportspec()' command? Perhaps delimiting all strings will help?

Also, the comma is the default seperator, so leave it blank just in case it's causing an issue.

Try this line instead:

RunExportSpec("Docs\ExportRef.txt","","",0,1,0,1,1,1,0,0)


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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Duplicate Record
Reply #11 - Dec 26th, 2010 at 2:05pm
Print Post Print Post  
Thank you very much Steve, can't thank you enough. I guess I'm not focusing well enough at times. I should have thought about the ability to change the separator but it never crossed my mind.

I tried several different separators and ended up using a pipe "|".  Could there be any negatives in using the pipe?

RunExportSpec("Docs\ExportRef.txt","|","",0,1,0,1,1,1,0,0)

This works beautifully.

Merry Christmas,

Brandon

  
Back to top
IP Logged
 
Steve_in_Texas
Senior Member
*****
Offline


No personal text

Posts: 893
Location: San Antonio
Joined: Feb 21st, 2004
Re: Duplicate Record
Reply #12 - Dec 26th, 2010 at 2:59pm
Print Post Print Post  
Sounds good. the pipe (|) and carrat symbol (^) seem to be good delimitters, but maybe you should also run the replace() command just prior to change any instance of | to something different just to be safe with the export:

vNotes = @Replace(Customernotes, "|", " - ")
Customernotes = vNotes

Merry Christmas.

Steve


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



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: Duplicate Record
Reply #13 - Dec 26th, 2010 at 3:10pm
Print Post Print Post  
OK, I'll do that, good advice.

Upon further testing, with using all the symbols except the pipe, there still is one, or a combination of them, that are causing the trouble. However, the majority of the data within those fields are using more of the standard symbols such as , : $ ! () = + - and those do not appear to be causing any trouble.

Thanks again,

Brandon
  
Back to top
IP Logged
 
Amor
Full Member
Members
***
Offline


No personal text

Posts: 366
Location: Germany
Joined: Feb 7th, 2004
Re: Duplicate Record
Reply #14 - Dec 26th, 2010 at 4:44pm
Print Post Print Post  
Hello!

I think you donīt need any replace.

Try this line instead: 

RunExportSpec("Docs\ExportRef.txt", "", "", 0, 0, 0, 0, 0, 0, 0, 0)
  

Dr. med. Amor Belhareth&&Medizin Labor &&Germany
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send Topic Send Topic Print Print