importing old DBF files

Posted on 2001-06-14
Last Modified: 2011-09-20
What's my best route? I have an old dbf file. The transaction table has a link field set up as follows:

Customer No.   Date    Item
1              6/15/01  d8fj98

now, this is kinda like a reciept for two items.
Item d8f is one item and item j98 is another. My problem is that I am creating a new database and do not want to loose this info. Any suggestions.

The way I set up databases would be to have a table that would link by a transaction number and have two entries.

Question by:RKeliher
  • 7
  • 4
  • 2

Expert Comment

ID: 6194617
You will get your exact table stucture  from the dbase, you will have to set up your relationships,if you have more then one table.just creat a new acess Db ,File>
get external data > Import.  pick the file location, and in the files of type down the bottom, pick dbase(dbf)
most likely it will be version 5, or if you know pick the correct version, if not start with the newest (highest #) and work your way back !
Is this what you are asking ?
LVL 57
ID: 6194942
Import the table as is first, then setup a new table and split the records the way they should be.

You should be able to import the DBF directly.  If not, first save the DBF file (with your old app) as a text file, then import to Access.

If you only have the file, feel free to send it along and I'll get it imported for you.  I have all versions of Access plus a varity of tools that I can use (like Data Junction).


Expert Comment

ID: 6195027
if you have one table called Item,create two new fields Item1   and   Item2 , make a new query and hit design view,just close show table , go to view menu and pick SQL and paste this
UPDATE tblTransaction SET tblTransaction.Item1 = Left([Item],3), tblTransaction.Item2 = Right([Item],3);
this is set up for Item,Item1,Item2, if table names vary change here,item has data, and the other will be your new fields,when done you can delete item
  In query, hit view and change back to design view
LVL 57
ID: 6195500

"if you have one table called Item,create two new fields Item1   and   Item2 , make a new query and hit
design view,just close show table , go to view menu and pick SQL and paste this"

 That would result in a bad design because you would be breaking some normalization rules.  They should be seperate records if they represent two different things.


LVL 57
ID: 6195506
I probably should add to bit and say that this is always what kills some older conversion efforts.  When you move from a non-relational to a relational DBMS, the design must change.  Data just can't be stored the same way.


Author Comment

ID: 6195643
I have several DBF files. One is customers, one is items, one is transactions.
The orginal creator tried to make it relational, but stored the info in the transaction file improperly. I'm trying to figure out a way to fix it so that I can keep all data in the program I'm trying to put together.
The data in the transaction table takes the first three letters (he did not use numbers) of each item ID and puts them all together as seen in the example above. It also does the same with the price field. Here's what it looks like
(this is in one record)
Item - om2ifc
Price -  4500 2000

I noticed that he put a space inbetween the prices but not in the item. Although if the item id is only 1 or 2 letters, then it looks like this
i1 ind
There is a space representing the third letter.

Do either of you know how I might fix this?

I would like the layout to be as follows
Transaction ID

Then there would be two records, but they would each have the same Transaction ID.

Thank you
Please let me know if this sounds confusing, I can send a portion of the database over if needed.

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

LVL 57
ID: 6195909
Import the DBF tables as is.  Setup new tables as you need.  Then execute two append queries, which use the DBF table as input and your new tables for output.

The first query would set the item field as underground indicated:


and the cost with:

Left([price],instr([Price]," ")-1)

second query would do:


for item and

Mid([Price],instr([Price]," ")+1)



Author Comment

ID: 6196645
Would this work if there are 9 or 12 items?
Everything in the item field is divided by 3
LVL 57
ID: 6202248

  Yes it would work.  You'd just have to adjust the query each time to look in the right place.  Sounds like it would be better to use code though to do this.  VBA now has a Split function which takes a string and breaks it up into parts based on some delimiter.  In your case, this would be a space.

But what I wondering is if you have any item descriptions that are more then one word<g>.


Author Comment

ID: 6202591
The least amount of an item code is 3 letters or numbers, the most I have found is 12.
I really don't mind doing the queries. I'm not familiar enough with code at this point.
Can you help me to take the item code field and append the first three letters or numbers to a new field called item1, then run another query to take the second three letters or numbers and append them to a field called item2, then do the same with the next set of letters and numbers, etc.

LVL 57

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 100 total points
ID: 6202892
<<Can you help me to take the item code field and append the first three letters or numbers to a new field
called item1, then run another query to take the second three letters or numbers and append them to
a field called item2, then do the same with the next set of letters and numbers, etc.

 As I pointed out earlier, it is wrong from a relational point of view to have "Item 1, Item 2, Item 3" all in one record.  They should be seperate records.

Your table structure will be this:

Date  (rename this to something else - 'DATE' is a reserved word)

First import the DBF table as is.

Next build a select query against the imported table. Select the customer and date fields and place them in the grid.  For the Item column, enter:

NewItem: Mid([Item],1,3)
NewPrice: GetToken([Price],1)

GetToken() is the following function that you need to paste in to a module:

Function GetToken(strParam As String, intTokenNumber As Integer) As String

  Dim aStrings() As String

  aStrings = Split(strParam, " ", -1, 1)

  GetToken = aStrings(intTokenNumber - 1)

End Function

 Now run the query.  You should see the correct data.  Switch back to design view, click on query/append.  You'll be prompted for the table name you want to append to.  This will be the new table.

After that, you'll see a new row in the grid called "append to".  On that row, indicate which fields each column should be placed into.  Then execute the query.

Create another query for the 2nd item the same way but for item and price:

NewItem: Mid([Item],4,3)
NewPrice: GetToken([Price],2)

for the 3rd it will be
NewItem: Mid([Item],7,3)
NewPrice: GetToken([Price],3)

and so on.


Author Comment

ID: 6209008
Worked like a charm! Thank you so much. Great Job!!

BTW - I am trying to requery a field after update on a field that is in the subform. I know I can't do it with the macros, is there a way to do it in an event procedure.
LVL 57
ID: 6210116
Sure, it's:


 or if the code is in the subform:


  You just need to put the actual names of the form/controls in the [].


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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

911 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now