Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Importing data from .DAT file

Status
Not open for further replies.

merv805

Programmer
Apr 25, 2003
14
US
Im trying to import a text file with the extension .DAT. This text file was created by a scanning documenting system. These system files will be needed to be imported Access on a regular basis. I have tried to import using the "Get External Data" menu and went through the entire wizard, but when I click finish it says: Error file is read-only. My question is in regards to .DAT files. Are they recognized by Access or do they have to be coverted into .TXT files instead. If possible...how would you convert a file into a non-read only format if the checkbox in the file properties is already unchecked in WINDOWS 2000. If anyone can help me understand this problem would be greatfully appreciated. Thanks.
 
using the command prompt, you could use the attrib function to change the files attributes, or in access there are functions called setAttr and getAttr that can change the file attributes.

I am not sure if that is what you are looking for, but hopefully that gets you started.
 
I've had this problem, too.

I loop through the directory and rename the ".dat" files to .txt, then put them in the database. Here's a sample of some code that changes them to .txt:

On Error GoTo ErrHandler

Dim DirName As String
Dim FName1 As String
Dim FName2 As String
DirName = "C:\YourDirectory\"
FName1 = Dir(DirName + "*.dat")
Do Until FName1 = ""
FName2 = Left(FName1, Len(FName1) - 3)
Name DirName + FName1 As DirName + FName2 + "txt"
FName1 = Dir
Loop
Exit Sub

ErrHandler:
MsgBox Err.Description
Exit Sub

My files aren't read only, but you could use

SetAttr pathname, attributes

to change the attributes.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top