Is this the correct code to access and upload a text file from the desktop to the Inventory table in the NEW Inventory Scanner DB file in the Inventory folder on the J: drive? I keep getting a “this isn’t a valid path” violation. Whatsamatter?
DoCmd.TransferText acImportDelim, "Invent Import Specification", "Invent", "J:\Inventory\NEW Inventory Scanner DB\Inventory"
'Import daily Inventory file
Thanx...
modest
02-15-2005, 10:46 AM
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.txt")
strFile = ahtCommonFileOpenSave(InitialDir:=CurrentDb.Name, Filter:=strFilter, OpenFile:=True, DialogTitle:="Title of Window Goes Here")
If strFile = "" Then Exit Sub
DoCmd.TransferText acImportDelim, "Specification Name", "Table Name", strFile, False
This is the code I use to open a file using a dialog window. However if you didn't want to use a window and just keep it static in your code, just replace the "strFile" with the full location of your file, much like you have done, but include the "\filename.txt" too.
Additionally you're importing to table "Invent" you may want to check the name of your table and make sure it's not "Inventory"
-modest
PS to use the filter and the dialog insert the attached file as a module of your database, courtesy of Ken Getz.