Solved

dBase to Access

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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This collection of functions covers all the normal rounding methods of just about any numeric value.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

689 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