Runtime error 31519

  • Thread starter Thread starter John K
  • Start date Start date
J

John K

I tried the code here: http://www.mvps.org/access/api/api0001.htm to open
file dialog so the user can import the txt files they select.

The code I have follows (I used the code from his TestIt function and added
to that:

Private Sub Command0_Click()
Dim strFilter As String
Dim lngFlags As Long
'strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
'strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
'strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)

DoCmd.TransferText acImportFixed, FileImportSpec, tblImport, strFilter

Everything stops on the transfer text part and says error 31519 can't import
that type of file. I can right click in the database window and import the
files from there using the specs named above. It does not import correctly
if I try a macro either. I don't get the same error it just does not import
all the data, it dumps it off into an error table. Is there another setting
in the file specs setup that I may have missed? I have been fiddling with
this for 2 hours now. Kinda stuck...

Thanks,
John
 
Okay. I did get the code fixed and it will import via macro, the right click
in db window but not with the below. The code is fixed with the quotes, it
runs, but the tblImport does not fill in. There is an error table claiming
truncation on the first field. This field goes just fine with the other
methods. I am so confused. I need the users to be able to select the file
to be imported as they will have multiple files to import each day.

Any ideas?

John
 
Never mind. I retyped the entire line for DoCmd.transfertext and everything
is alright now. I have no idea what I effed up, but she be fixed now.
 
Back
Top