Showing posts with label 8. Export To Any Type DB. Show all posts
Showing posts with label 8. Export To Any Type DB. Show all posts

Export to Any Type of Database

Everyone tells you how to import, but even most MS-VB techs start coughing when you ask how to export with DAO! Use this code to get data out to different formats without requiring a complete copy of any DBMS on the user machine.

Create a new project with a command button and a DAO3.5 reference, then copy this code to the button's Click event (snippet assumes the MS sample file biblio.mdb is in the application path):

Dim db as database
Set db = Workspaces(0).OpenDatabase(app.path & "biblio.mdb")
'commented out syntax followed by working example
'db.execute "SELECT tbl.fields INTO [dbms type;DATABASE=path].[unqualified 'filename] FROM [table or tables]
db.execute "SELECT * INTO [dBase III;DATABASE="C:My Documents].[testa] FROM [authors]"

By using the brackets and dot operator, you get a completely proper output in the ISAM database type of your choice. Also, if you choose Text as the database type, the statement creates a Schema.ini for you automatically, or adds a new section for your new data file to a Schema.ini already in the path folder.

Now you can do any kind of export the client wants without using a DBMS on the machine. This makes your life easier when you notice that some of your users running Word97 have problems mail-merging with text files you originally created with traditional (and slower) Write# and Print# methods.

Tip by Robert Smith