tamara
Posts: 26
|
| Posted: 07/19/2006, 2:55 PM |
|
Hi ,
I was wondering if it is possible in CCS to retrieve information from one table and then turn around and insert that same information into another table. Any help would be greatly appreciated. I have been fighting with this for days.
Thanks,
Tamara
|
 |
 |
peterr
Posts: 5971
|
| Posted: 07/19/2006, 3:01 PM |
|
Sure: http://forums.codecharge.com/posts.php?post_id=42374
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
tamara
Posts: 26
|
| Posted: 07/20/2006, 7:31 AM |
|
In my case I am opening a form that is already populated with data from tableA and I want this data to be Inserted into tableB. Because of this I don't have the Insert button and can't get it to show. Is there a way around this?
Thanks for any help,
Tamara
|
 |
 |
peterr
Posts: 5971
|
| Posted: 07/20/2006, 3:55 PM |
|
I haven't tried this but logically it should work the same way as the above solution - you would just use the BeforeExecuteUpdate event instead of BeforeExecuteInsert. You can also replace UPDATE with INSERT in the SQL statement, similarly to replacing table names.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
wkempees
Posts: 1679
|
| Posted: 07/20/2006, 4:42 PM |
|
and you can change the button text or image to "Insert" too.
Just to make it totally obvious to your user (deducted from your post)
Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)
if you liked this info PAYPAL me: http://donate.consultair.eu
|
 |
 |
tamara
Posts: 26
|
| Posted: 07/21/2006, 6:00 AM |
|
I did all of that and it seems to work with no errors, but it does not write to the second table. It seems like this should be easy. Any suggestions?
Tamara
|
 |
 |
tamara
Posts: 26
|
| Posted: 07/21/2006, 2:05 PM |
|
I am getting this error now.
Syntax error converting the nvarchar value 'false' to a column of data type bit. (Microsoft OLE DB Provider for SQL Server)
It adds to the first table ok and the tables are identicle so I'm not sure what is happening. Is there any way to find a line number on the error?
Tamara
|
 |
 |
tamara
Posts: 26
|
| Posted: 07/22/2006, 3:43 PM |
|
Well.......I finally got the error to go away by changing the value for boolean in the server settings but when I tested the code, it overwrote all of the records in my database. I just finished restoring it. Does anyone have any other ideas on inserting a record from one table into another table?
Thanks,
Tamara
|
 |
 |
Waspman
Posts: 948
|
| Posted: 07/23/2006, 11:21 AM |
|
Sorry man, I've been there
Any road, when I want to take data from one table (or form for that matter) and stick it in another table I use..
Dim SQL1
Dim Connection1
SQL1 = "INSERT INTO Table1(Value1,Value2,Value3,Value4) "&_
"VALUES ("&CCToSQL(Table_Name.Field_name1.Value,ccsText) &","&CCToSQL(Table_Name.Field_name2.Value,ccsText) &","&CCToSQL(Table_Name.Field_name3.Value,ccsText) &","& CCToSQL(Table_Name.Field_name4.Value,ccsInteger) &")"
Set Connection1 = New clsDBConnection
Connection1.Open
Connection1.Execute(SQL1)
Connection1.Close
Set Connection1 = Nothing
Works fine for me.
Hope this helps
Tony
_________________
http://www.waspmedia.co.uk |
 |
 |
tamara
Posts: 26
|
| Posted: 07/24/2006, 11:41 AM |
|
Thanks Tony. I will try this out. Do you put this code in the Before Execute Update?
Tamara
|
 |
 |
Waspman
Posts: 948
|
| Posted: 07/25/2006, 1:19 PM |
|
I use it all over, before update and insert and I also use it before show when I log a users profile in my activity logs.
Tony
_________________
http://www.waspmedia.co.uk |
 |
 |
tamara
Posts: 26
|
| Posted: 07/29/2006, 12:11 PM |
|
Well...I keep getting Variable is Undefined error on the table name. Any suggestions?
|
 |
 |
Waspman
Posts: 948
|
| Posted: 07/30/2006, 3:48 AM |
|
Check the way you call the values.
(it happens all the time to me) spelling, syntax usual stuff.
Tony
_________________
http://www.waspmedia.co.uk |
 |
 |