Normal Topic Copying a record to another DB within the same App (Read 1342 times)
steviebabes
Member
*
Offline


No personal text

Posts: 4
Joined: Aug 23rd, 2005
Copying a record to another DB within the same App
Aug 23rd, 2005 at 7:19pm
Print Post Print Post  
I am fairly new to Sesame, so may well be doing something silly ;o)

What I am trying to achieve is to take a record from a form in one database and copy it to another form in another database within the same application.  I am having trouble putting the code together for what should surely be something simple?  What would anyone suggest with regards to code and any examples?

Thanks.
  
Back to top
 
IP Logged
 
putermann
Member
*
Offline


No personal text

Posts: 15
Joined: Jan 19th, 2005
Re: Copying a record to another DB within the same
Reply #1 - Aug 24th, 2005 at 2:28am
Print Post Print Post  
You don't need any code - sesame has a built-in copy function that'll do it in a second - look in your manual in the section on importing / exporting data. When you get there look at the section on copying records.

Putermann..
  
Back to top
 
IP Logged
 
steviebabes
Member
*
Offline


No personal text

Posts: 4
Joined: Aug 23rd, 2005
Re: Copying a record to another DB within the same
Reply #2 - Aug 24th, 2005 at 11:18am
Print Post Print Post  
Does this apply in both runtime and in design?  I am trying to do this functionality when a user presses a button to copy the records.
  
Back to top
 
IP Logged
 
putermann
Member
*
Offline


No personal text

Posts: 15
Joined: Jan 19th, 2005
Re: Copying a record to another DB within the same
Reply #3 - Aug 26th, 2005 at 2:11am
Print Post Print Post  
Yes - you can do the same things in Designer preview mode that you can do in Runtime - Copying the records is not a "press one button" operation though. You have to have both forms open. The one you're copying from should be in "update" mode and preferably you've already retreived the records you want to copy. Switch to the form you want to copy the records into. In the bottom left window where the element names are listed, look at the top of that window. There's a small arrow on the right. Click on it til the title at the top of the window says "copy to ----" then double click on the name of one of the elements listed in the window. A similar window will open showing the element names from both the open forms. One column will have the "source" element names, the other will have the names form the "destination" form that you'll copy to. Clickon the names (one at a time) in the destination list and drag them to the other window and match them with the correct ones from the source list. If the element names are the same in both forms you can press the "match names" button at the bottom and it'll happen automatically. If you don't want to copy from all the source elements (fields) just don't match them to anything. When your done, press the close button at the bottom. You should be back at you "destination" form. In the element window again, click the small down arrow at the top. One of the selections will say "run". Highlight that and you're done. Everything will be copied as you specified.

Happy Copying
Putermann..
  
Back to top
 
IP Logged
 
steviebabes
Member
*
Offline


No personal text

Posts: 4
Joined: Aug 23rd, 2005
Re: Copying a record to another DB within the same
Reply #4 - Aug 26th, 2005 at 8:43am
Print Post Print Post  
Thanks for your reply.

I have got this working as you described, but what I want to do is to do exactly the same thing programmatically.  Basically I want to have a button on the form I want to copy from, and when that button is pressed, the record(s) are then copied to the destination form.  I want to do this via clicking a button on my form which automates the process for my client.  Is this something that is possible?

I have tried opening the copy spec that I have saved and executing it via the code with the relevant forms open, but I just can't seem to get it to work.

Any ideas?????
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Copying a record to another DB within the same
Reply #5 - Aug 26th, 2005 at 11:36am
Print Post Print Post  
You could use multiple XLookup (or @XLookup) functions, or one @XLookupSourceList, to retrieve the data for each element. And of course, this could be activated with a command button.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Copying a record to another DB within the same
Reply #6 - Aug 26th, 2005 at 12:00pm
Print Post Print Post  
Once you have defined the copy spec, you can load the spec and run it programmatically.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
steviebabes
Member
*
Offline


No personal text

Posts: 4
Joined: Aug 23rd, 2005
Re: Copying a record to another DB within the same
Reply #7 - Aug 26th, 2005 at 12:06pm
Print Post Print Post  
I have defined and saved a copy spec, but every time I try to load it through the @loadcopyspec function it always returns as fail, and then I am not sure how to execute it once it has been loaded programmatically.

Not sure what I am doing wrong as I thought this would be fairly straight-forward.  Any code examples/ideas/suggestions would be really helpful.

Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Copying a record to another DB within the same
Reply #8 - Aug 26th, 2005 at 1:29pm
Print Post Print Post  
There was a bug in 1.1.2 (its been fixed in 1.1.3) so that spec names are case sensitive. Check your spelling and make sure the case matches.

To launch the spec use @SelectTreeItem.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged