Link to home
Start Free TrialLog in
Avatar of RKeliher
RKeliher

asked on

importing old DBF files

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.

Avatar of underground712
underground712

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 ?
Avatar of Jim Dettman (EE MVE)
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).

Jim.
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
undergorund712,

"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.

Jim.

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.

Jim.
Avatar of RKeliher

ASKER

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
Item
Price

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

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

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:

Left([Item],3)

and the cost with:

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

second query would do:

Mid([Item],4,3)

for item and

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

Jim.


Would this work if there are 9 or 12 items?
Everything in the item field is divided by 3
RKeliher
Yuck...

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

Jim.
Jim,
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.

RKeliher
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Worked like a charm! Thank you so much. Great Job!!
RKeliher

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.
Thanks
Sure, it's:

=Forms![myMainFormName]![mySubFormControName].Form![mySubformControlName].Requery

 or if the code is in the subform:

 Me![mySubFormControlName].Requery

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

Jim.