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


importing old DBF files

Posted on 2001-06-14
Medium Priority
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
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
  • 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 58
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 58
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 58
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.

LVL 58
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 58
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 58

Accepted Solution

Jim Dettman (Microsoft MVP/ EE MVE) earned 400 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 58
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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

618 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