Ok I've got the two files. I see you're doing some text manipulation in Excel, but what you're showing can't possibly be what you're attempting to import into access. What information on the actual text file are you attempting to get into an access table. There are ways to parse text files, extract the values you want and insert them into access tables but you'll have to have a good idea of how you are going to recognize text. There are a lot of 'blank' values on your text file which I assume are actually present on the real report (Application, Security Area, Authorized to Tasks, Task, Task Locked, Task Access, Task Authorized, User) Are you just trying to extract from the AOR line
AOR Display Production Receipts SEC CAS Y as a single string or is it your goal to have those as separate fields in an access table, further, are all of the values in ACCESS, AUTHORIZED, USER ID and NAME going to be part of that table?
If your goal is to get anything from the AOR line to the end of the report into an access database table you'll have to do some text file manipulation and I'd suggest using filesystemobject.
Also, what happens if you have a report that goes for multiple pages, are there formatting breaks on the text file?
the basic setup for parsing a text file with filesystemobject commands is this:
Code:
dim fs
dim fsFile
dim sline as string
dim sTaskID as string
dim sDesc as string
dim sType as string
dim sApp as string
dim sLocked as string
dim sAccess as string
dim sAuth as string
dim sUser as string
dim sName as string
dim db as database
dim sSQL as string
set db = currentdb
set fs = createobject("Scripting.filesystemobject"
set fsFile = fs.opentextfile("C:\amzatpfp.mod.txt")
sline = fsfile.readline
do while fsfile.atendofstream <> true
If left(trim(sline),3) = "AOR" then
sTaskID = Trim(Mid(sline,23,10))
sDesc = trim(mid(sline,46,40))
sType = Trim(Mid(sline,98,4))
sApp = Trim(mid(sline,104,4))
sLocked = Trim(mid(sline,112,1))
fsfile.readline 'Skips the line with the column headers for the detail of access, authorized userID and name
fsfile.readline
do until (insert a test if there are page breaks with other text any other reason to kick out of this loop)
sAccess = trim(mid(sline,48,1))
sAuth = trim(mid(sline,61,1))
sUser = trim(mid(sline,74,10))
sName = trim(mid(sline,86,12))
sSQL = "INSERT INTO MyTableName (Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9) VALUES( "
sSQL = sSQL & "'" & staskid & "',"
sSQL = sSQL & "'" & sdesc & "',"
sSQL = sSQL & "'" & sType & "',"
sSQL = sSQL & "'" & sApp & "',"
sSQL = sSQL & "'" & sLocked & "',"
sSQL = sSQL & "'" & sAccess & "',"
sSQL = sSQL & "'" & sAuth & "',"
sSQL = sSQL & "'" & sUser & "',"
sSQL = sSQL & "'" & sName & "')"
db.execute ssql
sline = fs.readline
loop
Endif
sline = fsfile.readline
loop
set db = nothing
You'd obviously have to put in your own table and field names to make it work AND put in a secondary test that will kick you out of the SQL portion IF this report has mutliple sections. I haven't tested the code so there may be typos or syntax errors but it's the basic framework.