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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Docmd.TransferText Can't find Object

Status
Not open for further replies.

perrymans

IS-IT--Management
Nov 27, 2001
1,340
US
If I use a file's complicated name, I get the error about not finding the object. If I use a simple name, it works.

Does Not Work= cdbackup.dfe.site.place.org-20090108-105442.csv.txt

Does Work= ggg.txt

I am using:

Code:
DoCmd.TransferText acImportDelim, , "Sheet1", sFile, False

Is there a way around this? Otherwise I have to parse and code each piece myself to grab all of the values with complex statements.

Thanks. Sean.
 
Nevermind, I used the following, which I kind of like better anyway.

Sean.

Code:
Function TextImport(Response As Integer, sFile As String)
On Error GoTo Err_Execute

   Dim cncurrent As ADODB.Connection
   Dim rsDiag As ADODB.Recordset
   Dim strFileName As String
   Dim strVersion As String
   Dim strLocalhost As String
   Dim strRemotehost As String
   Dim strUuid As String
   Dim strIPAddress As String
   Dim strMACAddress As String
   Dim strOS As String
   Dim strAdmin As String
   Dim strOrg As String
   Dim dteDateTime As Date
   Dim strWheelCount As String
   Dim strLogs As String
   Dim strUserGroup As String
   Dim strShared As String
   Dim strAV As String
   Dim strIAVA As String
   Dim strPwdPolicy As String
   Dim strEnableLog As String
   Dim lngMaxID As Long
   Dim one, two, three, four, five, six, seven, eight, nine, ten As String
   Dim eleven, twelve, thirteen, fourteen, fifteen, sixteen As String

        'Import Text File
        Set cncurrent = CurrentProject.Connection
        Set rsDiag = New ADODB.Recordset
        
        'Open the table to insert the text file into
        
        strFileName = Mid$(sFile, InStrRev(sFile, "\") + 1)
        strSQL = "Select * from Tbl_INFOCON_INFO"
        
        rsDiag.Open strSQL, cncurrent, adOpenDynamic, adLockOptimistic
        
        Do While Not EOF(1)
            ' Read a line of data.
            Line Input #1, LineData
            
            'Parse the line to allow grabbing the first value
            one = Trim(Mid(LineData, InStr(LineData, ",") + 1))
            two = Trim(Mid(one, InStr(one, ",") + 1))
            three = Trim(Mid(two, InStr(two, ",") + 1))
            four = Trim(Mid(three, InStr(three, ",") + 1))
            five = Trim(Mid(four, InStr(four, ",") + 1))
            six = Trim(Mid(five, InStr(five, ",") + 1))
            seven = Trim(Mid(six, InStr(six, ",") + 1))
            eight = Trim(Mid(seven, InStr(seven, ",") + 1))
            nine = Trim(Mid(eight, InStr(eight, ",") + 1))
            ten = Trim(Mid(nine, InStr(nine, ",") + 1))
            eleven = Trim(Mid(ten, InStr(ten, ",") + 1))
            twelve = Trim(Mid(eleven, InStr(eleven, ",") + 1))
            thirteen = Trim(Mid(twelve, InStr(twelve, ",") + 1))
            fourteen = Trim(Mid(thirteen, InStr(thirteen, ",") + 1))
            fifteen = Trim(Mid(fourteen, InStr(fourteen, ",") + 1))
            sixteen = Trim(Mid(fifteen, InStr(fifteen, ",") + 1))
            
            strVersion = Trim(Left(LineData, InStr(LineData, ",") - 1))
            strLocalhost = Trim(Left(one, InStr(one, ",") - 1))
            strRemotehost = Trim(Left(two, InStr(two, ",") - 1))
            strUuid = Trim(Left(three, InStr(three, ",") - 1))
            strIPAddress = Trim(Left(four, InStr(four, ",") - 1))
            strMACAddress = Trim(Left(five, InStr(five, ",") - 1))
            strOS = Trim(Left(six, InStr(six, ",") - 1))
            strAdmin = Trim(Left(seven, InStr(seven, ",") - 1))
            strOrg = Trim(Left(eight, InStr(eight, ",") - 1))
            dteDateTime = Trim(Left(nine, InStr(nine, ",") - 1))
            strWheelCount = Trim(Left(ten, InStr(ten, ",") - 1))
            strLogs = Trim(Left(eleven, InStr(eleven, ",") - 1))
            strUserGroup = Trim(Left(twelve, InStr(twelve, ",") - 1))
            strShared = Trim(Left(thirteen, InStr(thirteen, ",") - 1))
            strAV = Trim(Left(fourteen, InStr(fourteen, ",") - 1))
            strIAVA = Trim(Left(fifteen, InStr(fifteen, ",") - 1))
            strPwdPolicy = Trim(Left(sixteen, InStr(sixteen, ",") - 1))
            strEnableLog = Trim(Mid(sixteen, InStr(sixteen, ",") + 1))
                        
            rsDiag.AddNew
            rsDiag!VERSIONINFO = strVersion
            rsDiag!LOCALHOST = strLocalhost
            rsDiag!Remotehost = strRemotehost
            rsDiag!UUID = strUuid
            rsDiag!IPADDRESS = strIPAddress
            rsDiag!MACADDRESS = strMACAddress
            rsDiag!OS = strOS
            rsDiag!ADMINID = strAdmin
            rsDiag!ORGNAME = strOrg
            rsDiag!TIMESTAMP = dteDateTime
            rsDiag!WHEELCOUNT = strWheelCount
            rsDiag!LOGS = strLogs
            rsDiag!USERSGROUPS = strUserGroup
            rsDiag!SHARED = strShared
            rsDiag!AV = strAV
            rsDiag!IAVA = strIAVA
            rsDiag!PASSWORDPOLICY = strPwdPolicy
            rsDiag!ENABLEDLOGGING = strEnableLog
            rsDiag!FileName = strFileName
            rsDiag.Update
        Loop
        
        ' Close the data file.
        Close #1
        rsDiag.Close
        
        Response = 1
    
Exit Function

Err_Execute:
    Select Case Err.Number
    Case 3376
        Resume Next
    Case Else
        MsgBox "TextImport " & Err.Number & ": " & Err.Description & " with: " & sFile
        Response = 2
        Close #1
        Exit Function
    End Select
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top