Hello,
I am required to convert a dat file into access and structure the information as per the desired output. Initially I had thought that the file to be converted into access is in txt format and hence I wrote the complete code accordingly. I just learnt that the file will be available in .DAT format and hence I have to rewrite the code.
I had used the FileSystemObject and OpenTextFile method to import the data. Is it possible that I tweak this part so that the user has the option to open both in txt and DAT format. I am a novice in programming and even obvious things appear blurred to me ?
This is the part of the code that enables user to open the txt files. Please suggest the ways to enable user to open both txt and dat files….I am trying not to change anything else in the code as it is all interconnected and will lead to cascade effects.
Thanks for the help.
I am required to convert a dat file into access and structure the information as per the desired output. Initially I had thought that the file to be converted into access is in txt format and hence I wrote the complete code accordingly. I just learnt that the file will be available in .DAT format and hence I have to rewrite the code.
I had used the FileSystemObject and OpenTextFile method to import the data. Is it possible that I tweak this part so that the user has the option to open both in txt and DAT format. I am a novice in programming and even obvious things appear blurred to me ?
This is the part of the code that enables user to open the txt files. Please suggest the ways to enable user to open both txt and dat files….I am trying not to change anything else in the code as it is all interconnected and will lead to cascade effects.
Code:
Dim fs As FileSystemObject
Dim dfile As Object
Dim dline As String
Set RS = CurrentDb.OpenRecordset("Select * from Data")
'Code to import raw data
If IsNull(filepath) = False Then
Set fs = CreateObject("Scripting.FileSystemObject")
If fs.FileExists(filepath) Then
Set dfile = fs.OpenTextFile(filepath)
Do While dfile.AtEndofStream <> True
dline = dfile.ReadLine
If InStr(1, dline, "Opening Balance") <> 0 Then
RS.AddNew
RS("AllData") = "BALANCE"
RS.Update
End If
RS.AddNew
RS("AllData") = dline
RS.Update
Loop
End If
End If
Thanks for the help.