Transfer data from record A(database A) to record B(database B) 
Author Message
 Transfer data from record A(database A) to record B(database B)

I have the following problem:

I have two databases, database A and database B.
Database A has several records and one record (record X1)  is the same
as record X2 in database B.
I want to transfer the data (not the structure, or the complete table)
from record X1 in database B to record X2 in database A.

I already tried to do this with a query, but I didn't succeed.

Can someone help  me with this??

Ciao,

Philip



Sat, 05 Aug 2000 03:00:00 GMT  
 Transfer data from record A(database A) to record B(database B)

Hmmm..., interesting.  I don't know if we are both just missing something obvious or you can't do this easily.  But as a quicker way of accomplishing the task than copying each value by name you could try using the field collection.  I didn't actually try it but it has to be much easier.

This isn't the exact syntax but you can work that out.

db1.append
for i = 0 to db1.Fields.count - 1
 db1.field(i) = db2.field(i)
next i
db1.update

Regards
Barry

    I have the following problem:
    I have two databases, database A and database B.
    Database A has several records and one record (record X1)  is the same as record X2 in database B.
    I want to transfer the data (not the structure, or the complete table) from record X1 in database B to record X2 in database A.

    I already tried to do this with a query, but I didn't succeed.

    Can someone help  me with this??

    Ciao,

    Philip



Sat, 05 Aug 2000 03:00:00 GMT  
 Transfer data from record A(database A) to record B(database B)

Try using recordsets for each table and using a loop statement to move the
records over.

Dim dbA as Database
Dim dbB as Database
Dim rsA as Recordset
Dim rsB as Recordset
Dim iX as Integer

Set dbA = workspaces(0).OpenDatabase("C:\Path\dbA.mdb")
Set dbB = workspaces(0).OpenDatabase("C:\Path\dbB.mdb")
Set rsA = dbA.OpenRecordSet(SQLStatment,dbOpenSnapShot)
Set rsB = dbB.OpenRecordSet(TableName,dbOpenTable)
rsB.Index = "IndexName"

if rsA.RecordCount = 0 then Exit Sub ' or Function
rsA.MoveFirst
Do While Not rsA.EOF
      rsB.AddNew
      Ffor iX = 0 to rsA.Fields.Count - 1
             rsB.Fields(iX) = rsA.Fields(iX)
      Next iX
      rsB.Update
      rsA.MoveNext
Loop
rsA.Close
rsB.Close
set rsA = Nothing
set rsB = Nothing
dbA.Close
dbB.Close
set dbA = Nothing
set dbB = Nothing

Hope that works for ya,

Chat
VB Developer for PC Scale

"Genius's and Fools, were all alike under God's eyes." - Unk



Sat, 05 Aug 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. strange error trying to delete file with .aspx page (security policy, trust level BS)

2. Programador de Visual Basic ( Bs. As. - Argentina )

3. Visual Basic depeloper ( Bs. As. Argentina )

4. Inkjet Printer Cartridge REFILL Kits - bs

5. OLEPRO32.DLL And Microsoft's B.S.!!!!

6. strange error trying to delete file with .aspx page (security policy, trust level BS)

7. NT SERVICE CONTROL - FREE (No spam, no BS, no registration)

8. Designing queries and other VB BS

9. Transferring queried database records to array variable

10. Help: retrieve LAST record on database of 50.000 record

11. Recording a "record" in a database

12. Recording a "record" in a database

 

 
Powered by phpBB® Forum Software