Converting an Access table into .DBF


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Converting an Access table into .DBF

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Converting an Access table into .DBF

    [Originally posted by Mr. D]

    Hello.

    Is it possible to convert individual tables of an Access .MDB file into corresponding .DBF files through VB code? My program requires that Access tables be converted before sending them thru e-mail to a specified destination. If for instance, I have the following tables (with data already) in my .MDB file:

    Table1
    Table2

    can these be converted into, say, Table1.DBF and Table2.DBF (or any specified filename) which can then be opened and read by a dBase or Clipper databse utility program? If possible, how can the structure or the data type of field names be preserved? How about if the tables have one or more indexes? Can these be converted also into .NTX (Clipper) or .NDX (dBase) files?

    Thanks for the info in advance!

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Converting an Access table into .DBF

    [Originally posted by Stephan]

    it's easy !
    go to references, add MS Access 8.0 Object Library and create an instance to "Access" and you can use all features like in Access to export all your tables in different formats (dbase, excel, Text and so on)

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Converting an Access table into .DBF

    [Originally posted by Mr. D]

    Thank you for the reply. Actually, I haven't gone that far yet in VB. Will you be able to show me in code the things that you are suggesting?

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Converting an Access table into .DBF

    [Originally posted by Stephan]

    Hi, here my answer ( just one possibility ),
    any comments to
    stephan.lehmann@planet-interkom.de

    also a good tip, look in \SAMPLE-directory VISDATA.VBP


    ' Export Table from MDB-File into
    ' DBF-File-Format
    ' for dBase/Clipper

    Dim mdb_Table As String
    Dim dbf_Table As String
    Dim sql_statement As String
    Dim path_target As String
    Dim dbf_target As String

    ' declare Database-Object
    Dim MyDB As Database

    ' Source MDB-File
    mdb_Table = "C:\allpst\allpstneu.mdb"

    ' Table in MDB-File
    dbf_Table = "plan"

    ' Target-directory
    path_target = "C:\test"

    ' Target-DBF-File
    dbf_target = "newdbf"

    ' SQL-Statement
    sql_statement = "SELECT * INTO [dBase IV;database=" & path_target & "]." & dbf_target & " FROM " & dbf_Table
    'sql_statement = "SELECT * INTO [dBase IV;database=C:\test].newdbf FROM person"

    ' open the MDB-Database
    Set MyDB = DBEngine.OpenDatabase(mdb_Table)

    ' delete DBF-File before "copying"
    If UCase(Dir(path_target & "\" & dbf_target & ".dbf")) = UCase(dbf_target & ".dbf") Then
    Kill path_target & "\" & dbf_target & ".dbf"
    End If

    ' SQL-Statement and transfering data
    MyDB.Execute sql_statement

    ' close MDB
    MyDB.Close

    Set MyDB = Nothing

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Re:Converting an Access table into .DBF

    [Originally posted by Mr. D]

    Thanks again for the reply. Your code worked! I was also able to open and view the created .dbf file in my Clipper database utility program. I noticed that no error occured even though I did not put the Microsoft Access 8.0 Object Library reference.

    I have one question, though. What if my Access table has an index, say on the first field? In Clipper and/or in dBase, there are separate files for indexes, .NTX for Clipper and .NDX (I think) in dBase. Will these files be created also?

    Thanks again! You're a great help!

    (I have also sent this response to your email add.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center