Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

dBase to Access

Posted on 1997-05-21
3
Medium Priority
?
422 Views
Last Modified: 2013-11-24
I need to read any dBase 4 file and convert it automatically to an Access file with the same field structure.

However, i cannot read the dbase file and find out the fieldproperties.

Wh can help me??

Thanks
0
Comment
Question by:admannien
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Expert Comment

by:mikekr
ID: 1426467
I think the easiest would be to import your existing dBase files into MS Access. In MS Access ver 7, click on the Tables tab, click the New button, and select Import Table from the list. Click OK and a window will open asking for details of the import. From Combo Box tiltled Files of type, you can select dBase III, dBase IV, or dBase V.

If you have to code it, try the following... I haven't tried this myself, but I guess it would work. Attach the dBase file to an existing Access (MDB) at run-time, and then use the normal collections to return information about the attached dBase table.
0
 

Author Comment

by:admannien
ID: 1426468
I really have to code it in visual basic without useing access.

It has to be a kind of file converter.
0
 
LVL 3

Accepted Solution

by:
ChrisLewis earned 200 total points
ID: 1426469
Not an easy question, but here you go:

You will have to change your table names

Private Sub Command1_Click()
  Dim wrkJet As Workspace
  Dim dbConvert As Database
  Dim tdef As TableDef
  Dim tdef2 As TableDef
  Dim iCount As Integer
  Dim iCount2 As Integer
  Dim fldField1 As Field
  Dim fldField2 As Field
  Dim prpLoop As Property

  If Len(Dir$("C:\CONVERT.MDB")) <> 0 Then
    Kill "C:\CONVERT.MDB"
  End If
 
  ' Create Microsoft Jet Workspace object.
  Set wrkJet = Workspaces(0)
  Set dbConvert = wrkJet.CreateDatabase("C:\CONVERT.MDB", dbLangGeneral)
  'Attach dbase file
  Set tdef = dbConvert.CreateTableDef("DBaseFile")
  tdef.Connect = "dBase III;DATABASE=C:\"
  tdef.SourceTableName = "County"
  dbConvert.TableDefs.Append tdef
 
  'Create new table w/ exact fields
  Set tdef2 = dbConvert.CreateTableDef("NewTable")
  For iCount = 0 To tdef.Fields.Count - 1
    Set fldField1 = tdef.Fields(iCount)
    Set fldField2 = tdef2.CreateField()
    For iCount2 = 0 To fldField1.Properties.Count - 1
      On Error Resume Next
      fldField2.Properties(iCount2).Value = fldField1.Properties(iCount2).Value
      fldField2.Properties(iCount2).Properties("Inherited") = fldField1.Properties(iCount2).Inherited
      On Error GoTo 0
    Next
    tdef2.Fields.Append fldField2
  Next iCount
  dbConvert.TableDefs.Append tdef2
 
  'Copy Records
  dbConvert.Execute ("INSERT INTO NewTable SELECT * FROM DBaseFile")
 
  'You should delete the attatchment to the DBase file here:
 
  dbConvert.Close
  wrkJet.Close
End Sub


0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question