UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Error importing data...    
 
   
jaredvs
post Apr 7 2007, 11:56 AM
Post#1



Posts: 91
Joined: 25-September 03



Runtime error '31519
You cannot import this file...
line is code is
DoCmd.TransferText acImportFixed, "LABEL DAT IMPORT SPECS", "UPC_CODE", "S:\jstaks\LABEL.DAT", False, ""
Go to the top of the page
 
GroverParkGeorge
post Apr 7 2007, 02:02 PM
Post#2


UA Admin
Posts: 32,599
Joined: 20-June 02
From: Newcastle, WA


A few thoughts.
First, when you omit the last optional elements of the function, you don't need to include anything.
DoCmd.TransferText acImportFixed, "LABEL DAT IMPORT SPECS", "UPC_CODE", "S:\jstaks\LABEL.DAT", False
Also, does the specification to which you refer actually exist (I assume it must, but it's always good to check each element when trouble-shooting ).
Does the table named "UPC_Code" actually exist. Same point, verify everything.
Third, does the file named "S:\jstaks\LABEL.DAT" exist.
Fourth, are the field names in this file identical to the field names specified in the import spec?
Fifth, do all of the fields in the import spec exist in the destination table?
Sixth, is "S:\jstaks\LABEL.DAT" actually a fixed width text file?
HTH
George
Go to the top of the page
 
jaredvs
post Apr 7 2007, 02:17 PM
Post#3



Posts: 91
Joined: 25-September 03



Well here is a little background this file and stuff work with Access 97 but not 2003... and that is the only diffrenece
Go to the top of the page
 
GroverParkGeorge
post Apr 7 2007, 02:20 PM
Post#4


UA Admin
Posts: 32,599
Joined: 20-June 02
From: Newcastle, WA


I see that now. Sorry.
2003 is rejecting the file because it is not recognizing it as a txt file with the .dat extension.
Interesting. I'm going to go off and do a little research here.
I'll post back when I get anything more.
I'm also going to post a request for additional assistance.
George
Go to the top of the page
 
niesz
post Apr 7 2007, 02:51 PM
Post#5


Utter A-fishin'-ado
Posts: 17,958
Joined: 1-August 05
From: Cincinnati, Ohio, USA . . . ><((((°>


Starting with Access 2000, Microsoft has put some "security measures" into place that only certain types of files can be imported. This knowledgebase article shows two methods to work around this.
. A registry hack
2. Rename the file (temporarily or permanently with code) while the file is being imported.
Go to the top of the page
 
GroverParkGeorge
post Apr 7 2007, 03:09 PM
Post#6


UA Admin
Posts: 32,599
Joined: 20-June 02
From: Newcastle, WA


THanks, Walter. Once again I am in your debt.
eorge
BTW: Ken Snell just referred me to that same KB as well. You and he, great minds and all that....
Go to the top of the page
 
jaredvs
post Apr 7 2007, 03:16 PM
Post#7



Posts: 91
Joined: 25-September 03



Ok I found another work around... I added the file extensions to the registry and that worked as well...
but now I am still having another problem....
The search key was not found in any record. (Error 3709)
DoCmd.TransferDatabase acImport, "dBase III", "S:\jstaks\", acTable, "ezlabel.dbf", "brakes", False
again this worked in 97 but not in 2003
Go to the top of the page
 
jaredvs
post Apr 7 2007, 03:18 PM
Post#8



Posts: 91
Joined: 25-September 03



thanks guys so far for your help....!!! you guys are great!!!
Go to the top of the page
 
jaredvs
post Apr 7 2007, 04:09 PM
Post#9



Posts: 91
Joined: 25-September 03



any ideas on this last one???
Go to the top of the page
 
jaredvs
post Apr 7 2007, 04:45 PM
Post#10



Posts: 91
Joined: 25-September 03



I think I found the answer to my last one... it seems to be something that Access 97 ignores and 2003 doesn't but who ever creates this DBF file had a row of Delete#'s causeing 03 to blow up and all I did was open it up in excel and resave it and it worked just fine....
Go to the top of the page
 
GroverParkGeorge
post Apr 7 2007, 05:44 PM
Post#11


UA Admin
Posts: 32,599
Joined: 20-June 02
From: Newcastle, WA


I can't speak to the dbf file, I've been thinking about importing text files.
Here's a function I modified from the one in the KB article. It imports any VALID TEXT file regardless of the extension it has been given. Note that you still have to assign valid extensions within the function. I only included one for this example: .dat
CODE
Public Function fImportNonTXTFiles(strImportFile As String, strImportSpec As String, _
strDestinationTable As String)
On Error GoTo errHandler
Dim FLength, Fext, FOrig
' FOrig holds the file's original name
' The file will be renamed to its original name after it is imported
FOrig = strImportFile
' Get the length of the file name.
'We'll need this to remove the extension and replace it with a ".txt" extension for import.
FLength = Len(strImportFile)
' Set Fext = to the last four characters of the file name.
Fext = Right(strImportFile, 4)
' Add any valid extension for your application to this case select list.
' However, all files MUST be fixed width text tables regardless of extension.
Select Case Fext
Case Is = ".dat"
    strImportFile = Left(strImportFile, (FLength - 4))
    ' Add the .txt to the file name.
    strImportFile = strImportFile & ".txt"
    ' Transfer the file to a new table.
    Name FOrig As strImportFile
Case Is = ".csv", ".txt" 'Fire away with valid txt extensions
Case Else
    ' If there is no valid extention on the file, it may be a valid text table, or it may not be
    'Let the user decide at run-time
    If MsgBox("You can only import valid text files with approved extensions." & vbCrLf & _
        "If you are sure this is a valid text file with no extenion, click ""Yes"" to import it.", _
vbYesNo, "Not a Valid File Type") = vbYes Then
        strImportFile = strImportFile & ".txt" 'append the required extension
        Name FOrig As strImportFile
    Else
        GoTo exitProc
    End If
End Select
DoCmd.TransferText acImportFixed, strImportSpec, strDestinationTable, strImportFile, True
' After thecontents of the file are transferred, rename it back to
' its original name.
Name strImportFile As FOrig
exitProc:
    Exit Function
errHandler:
        MsgBox Err & ": " & Err.Description
    Resume exitProc
End Function
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    27th May 2018 - 10:44 AM