Solved

dBase to Access

Posted on 1997-05-21
3
407 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 50 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
Viewers will learn the different options available in the Backstage view in Excel 2013.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

696 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