DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004

    Converting an Access table into .DBF

    [Originally posted by Mr. D]


    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:


    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

    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

    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

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

    [Originally posted by Stephan]

    Hi, here my answer ( just one possibility ),
    any comments to

    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

    Set MyDB = Nothing

  5. #5
    Join Date
    Aug 2004

    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
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

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

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.