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 / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Extracting file path and name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Apples76 - 02 Jul 2007 12:08 GMT
i have foud the following code on the access web and want to extract the file
name and path which is output to the msgbox. can anybody help extract the
variable to be saved in a control.

i have attached the event to the onclick event which triggers the file
search but does not save the variable for later use.

Function TestIt()
   Dim strFilter As String
   Dim lngFlags As Long
   Dim FleNme As String
   
   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!")
       FleNme = lngFlags
   
   ' Since you passed in a variable for lngFlags,
   ' the function places the output flags value in the variable.
   Debug.Print Hex(lngFlags)
End Function
Douglas J. Steele - 02 Jul 2007 13:42 GMT
Function TestIt()
   Dim strFilter As String
   Dim lngFlags As Long
   Dim FleNme As String

   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 (*.*)", "*.*")
   FleNme = ahtCommonFileOpenSave(InitialDir:="C:\", _
       Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
       DialogTitle:="Hello! Open Me!")
       FleNme = lngFlags
   MsgBox "You selected: " & FleNme

   ' Since you passed in a variable for lngFlags,
   ' the function places the output flags value in the variable.
   Debug.Print Hex(lngFlags)
End Function

Signature

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

>i have foud the following code on the access web and want to extract the
>file
[quoted text clipped - 24 lines]
>    Debug.Print Hex(lngFlags)
> End Function
Daniel - 02 Jul 2007 13:44 GMT
ahtCommonFileOpenSave(InitialDir:="C:\", _
        Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
        DialogTitle:="Hello! Open Me!")

Returns the filename/path of the file selected by the users.

Use can use the Dir Function to extract the filename from the full path.

So your best bet is to set the ahtCommonFileOpenSave(...)  to a variable and
then manipulate the variable as required.

Here's a sample I use for images.

   Dim strFilter As String
   Dim lngFlags As Long
   Dim Docpath, FileName, StartDir, driveletter As String
   
       strFilter = ahtAddFilterItem(strFilter, "Images Files",
"*.gif;*.jpeg;*.jpg;*.bmp;*.tif")
       StartDir = "c:\"
       Docpath = ahtCommonFileOpenSave(InitialDir:=StartDir,
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, DialogTitle:="Select
Document")
       
       If Not Docpath = "" Then
           FileName = Dir(Docpath)
           Me.imgPath = Docpath
       End If
Signature

Hope this helps,

Daniel P

> i have foud the following code on the access web and want to extract the file
> name and path which is output to the msgbox. can anybody help extract the
[quoted text clipped - 22 lines]
>     Debug.Print Hex(lngFlags)
> End Function
 
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



©2009 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.