Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

Import text file using a wildcard

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Database girl - 27 Jun 2007 14:16 GMT
I am running the following code to import all text files that all start with
the same 12 characters:
' Set the parameters to import the text file
      If Right(Me!txtFilePath, 1) = "\" Then
         strPath = \\mdb8\Global
      Else
         strPath = \\mdb8\Global& "\"
      End If
strFileName = "GlobalImport*.txt"
     
If FileExists(strPath & strFileName) = False Then
         msgbox "File " & strPath & strFileName & " Does not exist!",
vbCritical + vbOKOnly, "No File..."
         GoTo ExitImport
      Else
         GetName = Dir(strPath & strFileName)
      End If
'Does file name exist in directory
Public Function FileExists(FName As String) As Boolean
On Error GoTo Err_FileExists
  FileExists = False
  FileExists = (Dir(FName) <> "")
Exit_FileExists:
  Exit Function
Err_FileExists:
  Select Case Err.Number
  Case 76
     FileExists = False
     Resume Exit_FileExists
  Case Else
     msgbox Err.Number & vbCrLf & Err.Description, , "FileExistError"
     Resume Exit_FileExists
  End Select
End Function  

When I run the code it will not return any of the text files located in
"//mdb8/Global".  However, if I add a drive letter it works.  This is not
practical since I am referencing a network drive.  Any ideas on how I can get
about this???

Thanks
Database girl
Douglas J. Steele - 27 Jun 2007 14:37 GMT
If you can't use a mapped drive letter, then try a UNC
(\\server\share\folder\file)

Alternatively, you can use the code from
http://www.mvps.org/access/api/api0003.htm at "The Access Web" to determine
which drive letter is mapped to the share.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

>I am running the following code to import all text files that all start
>with
[quoted text clipped - 40 lines]
> Thanks
> Database girl
Database girl - 27 Jun 2007 15:38 GMT
Doug,

I had forgotten to put in the share name when I referenced the strpath in my
code.  Silly me!

Thanks for your help.

> If you can't use a mapped drive letter, then try a UNC
> (\\server\share\folder\file)
[quoted text clipped - 47 lines]
> > Thanks
> > Database girl
Eric Blitzer - 27 Jun 2007 15:14 GMT
A different approach would be to use a drive letter you know is available on
every machine like P: using the shell command

Shell "net use P: \\server\foldername"

then you could reference the drive letter.

I sure this is not as good as Doug's answer.

> I am running the following code to import all text files that all start with
> the same 12 characters:
[quoted text clipped - 38 lines]
> Thanks
> Database girl
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.