Copying a DBF file fails

I am working with a .DBF (MyTest.DBF) file which has plenty of records in it. For a new requirement I had to create a copy of the DBF file for a different application and rename it (MyTest_New.DBF).

When I ran a program and inserted records into MyTest_New.DBF, the same records got inserted into MyTest.DBF too. (And vice-versa) I am not sure how these two files are linked.

The program I ran, creates an MS Access database and creates MyTest_New.DBF as a linked table in it and then inserted records into it.

Is there a different way the DBF files should be created a copy of? Please advise.
Who is Participating?
SimonConnect With a Mentor Commented:
I see that you've put your question in the Foxpro topic area as well as Microsoft Access and Miscellaneous databases... Is the Foxpro application active while you're doing this copying? Did you check whether BDE was installed? I suspect that Foxpro is 'managing' everything in that folder and may see your new DBF as a partition of the original or a replication copy - it's many years since I did Foxpro development, and I'm not sure about its current abilities as an RDBMS.

Why do you need to have the DBF files in the same folder? Could you use a completely separate path for initial testing and confirm that your Access app can link to and update that DBF file independently?
It sounds like you created an alias (shortcut) from MyTest.DBF rather than a new copy of it. Did you copy a single DBF file to a different folder or create the copy alongside the original in the same folder?

Try googling "BDE DBF alias"  - I am guessing that you might have BDE installed
If you are working in MS Access then the "copy" means just the "link copy" but the target remains unchanged.

To copy the MyTest.DBF you have to find its physical location on disk and make a physical copy of the file to another disk location in e.g. Windows Explorer. Then you must create a new link in MS Access.

DBF files can consist of up to three parts:
MyTest.DBF - database table
MyTest.FPT - memo file
MyTest.CDX - index file
you have to copy all of them if they exist.

MS Access should be closed during the copy operation.
A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Angel02Author Commented:
I copied the DBF and pasted in a different folder. Then I renamed it and put it back in the original folder. I need to have both the files MyTest.DBF and MyTest_new.DBF in the same folder. Is that possible?

Then a VB application created a temporary Access database and created a linked table targeting MYTest.DBF and then inserted records to it. I did not physically copy a linked table in MS Access.

Also this DBF does not have a FPT or CDX. Is that a worry?
Yes, you can have many DBF files in one folder. The different filename is sufficient to recognize them.

The FPT and CDX files are optional and their existence depends on the DBF file structure. If you don't have them then it is OK.

I can say nothing about the VB application because it can contain anything... I just suppose it has some configuration which tells what DBF file to use and process.
Angel02Author Commented:
I did some tests and found this.
Even when I manually add these DBF files in an MS Access DB and run an UPDATE query in MS access on one of them, both MyTest.DBF and MyTest_new.DBF get updated. So it is not VB application's fault.

Then I added  MyTest.DBF and MyTest_new.DBF in a different folder (2) and when I updated MyTest_New.DBF in folder#2, it edited Mytest.DBF in folder#2 but did not update either DBF in Folder#1.

It looks like I cannot have  MyTest.DBF and MyTest_new.DBF in the same folder but I need to. Any suggestions?
Angel02Author Commented:
Also, whatever update I do, the last modified date of MyTest_new.DBF does not change in Windows Explorer. Only last modified date of MyTest.DBF changes. It looks like when I created  a linked table, it is just pointing to MyTest.DBF, even though I select MyTest_New.dbf as the target.
pcelbaConnect With a Mentor Commented:
Interesting... But it is not so easy to help without any knowledge of your environment...

OK, Access has problems to access long file names sometimes (valid for DBF files).

Rename MyTest_new.dbf to MyTST2.dbf and try again.  Access must be able to link two different files in one folder.

Also, how the links to DBF files were created in Access? If you update MyTest but the change appears in "two files" but the last update date remains unchanged on the second file then it means both links point to ONE single file only. In other words links are not correct.

You should download some (free) DBF files viewer and check the DBF files content. If you have FoxPro then use FoxPro preferably.

What driver do you use to access DBF files from Access?
What MS Access version do you use?
I can't shed any light on the current problem but I wanted to warn you that MS dropped support for the .dbf file format with A2013 so if you are thinking about "upgrading" soon, you will have to work around this somehow.

I am in the process of converting a FoxPro application to Access.  When I started, I had A2010 installed and so was able to link to the FoxPro files.  It turns out that I can continue to use those apps in A2013, probably because the supporting drivers are still installed.  It turns out that I can also create new links if I use the ODBC option.  It seems that just the .dbf option is gone from the ribbon but not the actual functionality as long as you stick to ODBC.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.