Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another Question: Does any one know how to export table to a disk

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to make a button to export some table to a disk. Then pop the disk in another computer. Push a button that will place the table information into another table on that computer. Both table will have the same name. Instead of copying the entire database. I try to do a module last night but It could not find the database called (A:\TranFileDB.mdb). The reason I need to do this is so that if there are new queries made they do not get wiped out. What they were doing is using LapLink and copying the database which wiped out any new queries. I would greatly appreciate help with this code. These users are realy bad at messing things up in a database. You can explain over and over again and they still mess it up. Thanks

Tig[puppy]
 
I use XML for this kind of thing. I am assuming you are using Access 2000 and ADO. If not I can not help you.

This first piece of code will copy the contents of a tabel to a floppy disk as an XML file. Put this in the click event of a command button.

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic

rst.Open "Select * From TableName"
rst.Save "A\TableName.xml", adPersistXML

rst.Close
Set rst = Nothing

This code will open an XML file on a floppy disk and insert all the records in to a table. Put this in the click event of a second command button.

Dim rst As ADODB.Recordset
Dim rst2 As ADODB.Recordset

Set rst = New ADODB.Recordset
Set rst2 = New ADODB.Recordset

rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst2.ActiveConnection = CurrentProject.Connection
rst2.CursorType = adOpenKeyset
rst2.LockType = adLockOptimistic

rst.Open "A\TableName.xml", , , , adCmdFile
rst2.Open "SELECT * FROM TableName"

Do While Not rst.EOF
rst2.AddNew
rst2("Field1") = rst("Field1")
rst2("Field2") = rst("Field2")
'and so on..
rst2.Update

rst.MoveNext
Loop

rst.Close
rst2.Close
Set rst = Nothing
Set rst2 = Nothing

I hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top