Macro to Import a DBF File

  • Thread starter kev100 via AccessMonster.com
  • Start date

K

kev100 via AccessMonster.com

I've got an app that has a table created by Importing a FoxPro .dbf file.

Currently, I only need to occasionally "refresh" it by re-importing the same
file (the app that feeds data is in VizFoxPro and will only write to these
type files).

However, I now need to re-import it pretty often. Fortunately....it is
stored on only one place and will always have the same name.

Is it possbile to create a Macro to import this file?

If so....I could just have 1 Macro to delete the existing table and another
to import the file again into a new table (but with the exact same name of
the existing)....then have 3rd Macro that ties them all together.

Currently....to import, I do the following:

1. File / Get External Data
2. Select ODBC / Machine Data Source tab / Visual Foxpro Tables
3. Specify the Path and File name of the .dbf to be imported
4. Click OK
5. It imports the the data into a table with the SAME NAME as the source .dbf
6. I rename that imported table to something else so that all the forms /
queries / reports will work .

Any advice on creating such a query to import as above would be greatly
appreciated.

Thanks
 
Ad

Advertisements

K

Kernow Girl

Hi Kev - yes it would be no problem to create Macro to import / delete / etc.
You could have a macro to do it all or split it down into the various parts.
Making macros is dead simple.
Create a New Macro - Make sure you have 3 columns Macro Name, Action and
Comment. If not click the button on the toolbar with the xyz.
Give the macro a name - like Import Step, then in the Action column choose
TransferDatabase.
Go down a couple of lines and create another macro to delete the table -
action is DeleteObject

Create another macro and use the Rename action

Create buttons on your form and attach the Macros to the buttons.

If there are blank lines between the actions then you need to name each
macro. If no blank lines then it runs one command after the other. If you
want to do both - create the individual macros with names, then create a
macro that uses the RunMacro action.

I hope this helps --- Dika
 
Ad

Advertisements

K

kev100 via AccessMonster.com

Thanks VERY much....

I've not tried that yet...but it looks like exactly what's needed.

The database I'm importing is a VFoxPro table and it is done via ODBC. When
I do so manually, though, there other options that need to be specified
beyond the ODBC import-type.

Here is the manual proceedure:

1. File / Get External Data
2. Select ODBC / Machine Data Source tab / Visual Foxpro Tables
3. Specify the Path and File name of the .dbf to be imported
4. Click OK
5. It imports the the data into a table with the SAME NAME as the source .dbf

In the macro, the "TransferDatabase" does allow ODBC to be specified...but
not the other items (as far as I can tell)

I can't seem to find any other options under the TransferDatabase function
where these would be specified....do you think they are needed?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top