DoCmd.TransferDatabase

  • Thread starter Thread starter ooxx
  • Start date Start date
O

ooxx

Hi,

Hi holey.. excuse me.

My question is :
I want to import file type .DBF by using VBA code. Can any body show me
some examples?

Thanks,
 
We need a lot more information. You can't import an entire Access database
into the current database in one operation. Please provide some detail on
exactly WHAT you want to do. Then we can offer some suggestions on how.
 
DoCmd.TransferDatabase(TransferType, DatabaseType, DatabaseName, ObjectType,
Source, Destination, StructureOnly, StoreLogin)is taken from the VB help
file.

You would replace DataBase Type with "dBase III ", "dBase IV ", "dBase 5.0"

*IF* the .DBF file is in one of those formats. If not you might have to use
TransferText

Yours would look like
DoCmd.TransferDatabase acImport, "dBase III", _
"C:\MyDataBase.DBF", acReport, "NW Sales for April", _
"Corporate Sales for April"
 
Hi ,

Okey, as soon as I have tried the code you provided, Mike, it seems that it
would work, but the code is unlike the the type of Ms Access database that it
should point to the table or the "Table Name". Yes, DBF has no TableName. I
have tried one in DBF type but not success.

Another problem of me is when running the code in the type of Ms Access
database the root to the DbName, the code know where to extract. On the same
occassion, I do it on the DBF type, when running the code, it cann't, and
shown up the message "c:/Ex.DBF is not a valid path", eventhough, I have put
my file on the same root as running the code in type of MDB.

Thanks.
 
DBF files are typically flat file tables. It was used by dBase originally
and I've never seen a .dbf extension that was not just a single table. The
table name is the file name.

As for your "c:/Ex.dbf" it should be c:\Ex.dbf" and that assumes that you in
fact have it in "C:"

That is fairly rare today. If you are just copying the information from the
example you should realize that "C:\MyDataBase.DBF" is just an example.
Something like "C:\Documents and Settings\YourUserName\My
Documents\Some.dbf" is far more likely.
 
Hi,

I have tried and the outcome so gooood... for a time. But the time here, I
have one thing, I just want to know. With this code, DoCmd.TransferText
acImportDelim, , "MyTbl_Txta", "D:\GER\MDB\DB1\MyTxta.TXT", I 'd like to
shrink chars of field text to not more than 10 supposed, and to begin from
the 3rd letter supposed. Example of Field Txt: abCDEFGHIJKLmn opqrstuvwxyz,
so after extract the result in the field text would be : CDEFGHIJKL .

So, What would the solution here?
 
You will not be able to do that in the TransferText method. It is only for
moving data in and out of Access.
What you will need to do is use a temporary table that will accept the data
as is and use some queries to manipulate the data and populate your
production table with the reformed data.
 
Hi,

Are you sure? I don't think so. Acess must prepare that as an argument for,
but I don't know how to.

What do you think?

Access shouldn't ignore that.
 
Yes, I am sure.

ooxx said:
Hi,

Are you sure? I don't think so. Acess must prepare that as an argument
for,
but I don't know how to.

What do you think?

Access shouldn't ignore that.
 
I think I misread part of your original post.
If you have an odbc driver for DBase or Foxpro, you can connect to the dbf
as if it were a table and use a query to import the data.
 
If it delimited then you can't do it.
If it is fixed length you can.
There is no compelling reason to expect that what was important in one
database would not be important in the next.

Import it and run a query that uses the Mid function to pick the information
you need.

And, yes, we are sure.
 
Klatuu said:
I think I misread part of your original post.
If you have an odbc driver for DBase or Foxpro, you can connect to
the dbf as if it were a table and use a query to import the data.

You seem to have responded correctly to a second question as this appears to
be a delimited file.
 
Back
Top