We help IT Professionals succeed at work.

Import process

Explorer060599
on
hi experts,

l'm using msaccess 2000, l'm going to import 40 over file into access. as i know that is a import command in macro i can use, but it only open up the import file selection box for me. can i done all this programatically? any function or code for this ?

thanks for help.
Comment
Watch Question

Co

Commented:
Yes it can be done, using a schema.ini
If you put it in the same directory as the files you are importing. I'm assuming the files you want to import are text files.

If they are .xls you can use the transferspreadsheet functionality of access.

The schema.ini basically consists of information on every field. like this:

[yourtextfile.txt]
ColNameHeader = False
CharacterSet = ANSI
Format = FixedLength
Col1=Field1 Char Width 6
Col2=Field2 Integer
Col3=Field3 Boolean

You may also have a look at the transfertext possibility in VBA. It will also allow you to import text fields, but it is less flexible, because you will have to create each import-specification beforehand. And if even the slightest change occurs in the file you are importing (eg: a field more, or other length) the import will generate an error.

If you want a sample .mdb that imports text-files via a schema.ini automatically, just drop me an e-mail adress. I'll send it to you.

HTH,

Co

Author

Commented:
sorry to stated at first, l'm importing foxpro DBF file format. can it be done also ?
Commented:
yes - you could use VBA to import the code using the


DoCmd.TransferDatabase [transfertype], databasetype, databasename[, objecttype], source, destination[, structureonly][, saveloginid]

or

DoCmd.TransferText if you want to treat it as a text file

Author

Commented:
yes..that is what i want. but when i issued this command

DoCmd.TransferDatabase acImport, "dBase III", "C:\ZUCO\timecard.DBF", , "timecard", "timecard"

it came out error said invalid path. why ? the path is correct. its a bug ? when i using dbase 5 or dbase iv, then it said my database is not installed. what was missing ?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.