Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369

    Question Unanswered: Folder change/browse dialog

    In a function that gives only the administrator(s) (or the one with the pw...) access to turn the ByPassKey off by entering a pw, I have the following line:

    If strInput = "TypeYourBypassPasswordHere" Then ...

    - instead of storing the pw in the code, I would like to fetch that from a text file that I will keep on an encrypted drive, which will be open for normal file access whenever it is relevant to enter the pw/turn off DisabeByPassKey.

    I want to point to a text file name that cannot be changed (fixed in the code), but would like to offer a chance to direct which drive/folder Access looks for that particular file.

    So the PW dialog will offer to browse to a different folder if the file cannot be found, after the pw is entered. For security, I do not want the text file name to be visible, only offer to change to a folder , press "Look in this folder" or something (command button?).

    Can anyone help with code examples? I haven't done much API-or-the-like coding to get outside of access through VBA.

    D.

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Post

    Copy and past the next code in a new Module
    PHP Code:
    Type tagOPENFILENAME
        lStructSize 
    As Long
        hwndOwner 
    As Long
        hInstance 
    As Long
        strFilter 
    As String
        strCustomFilter 
    As String
        nMaxCustFilter 
    As Long
        nFilterIndex 
    As Long
        strFile 
    As String
        nMaxFile 
    As Long
        strFileTitle 
    As String
        nMaxFileTitle 
    As Long
        strInitialDir 
    As String
        strTitle 
    As String
        Flags 
    As Long
        nFileOffset 
    As Integer
        nFileExtension 
    As Integer
        strDefExt 
    As String
        lCustData 
    As Long
        lpfnHook 
    As Long
        lpTemplateName 
    As String
    End Type

    Private Type BROWSEINFO
      hOwner 
    As Long
      pidlRoot 
    As Long
      pszDisplayName 
    As String
      lpszTitle 
    As String
      ulFlags 
    As Long
      lpfn 
    As Long
      lParam 
    As Long
      iImage 
    As Long
    End Type

    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
                
    "SHGetPathFromIDListA" (ByVal pidl As Long_
                ByVal pszPath 
    As String) As Long
                
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
                
    "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO_
                
    As Long
                
    Private Const BIF_RETURNONLYFSDIRS = &H1

    Declare Function aht_apiGetOpenFileName Lib "comdlg32.dll" _
        Alias 
    "GetOpenFileNameA" (OFN As tagOPENFILENAME) As Boolean
    Declare Function aht_apiGetSaveFileName Lib "comdlg32.dll" _
        Alias 
    "GetSaveFileNameA" (OFN As tagOPENFILENAME) As Boolean
    Declare Function CommDlgExtendedError Lib "comdlg32.dll" () As Long
    Global Const ahtOFN_READONLY = &H1
    Global Const ahtOFN_OVERWRITEPROMPT = &H2
    Global Const ahtOFN_HIDEREADONLY = &H4
    Global Const ahtOFN_NOCHANGEDIR = &H8
    Global Const ahtOFN_SHOWHELP = &H10
    ' You won'use these.
    'Global Const ahtOFN_ENABLEHOOK = &H20
    '
    Global Const ahtOFN_ENABLETEMPLATE = &H40
    'Global Const ahtOFN_ENABLETEMPLATEHANDLE = &H80
    Global Const ahtOFN_NOVALIDATE = &H100
    Global Const ahtOFN_ALLOWMULTISELECT = &H200
    Global Const ahtOFN_EXTENSIONDIFFERENT = &H400
    Global Const ahtOFN_PATHMUSTEXIST = &H800
    Global Const ahtOFN_FILEMUSTEXIST = &H1000
    Global Const ahtOFN_CREATEPROMPT = &H2000
    Global Const ahtOFN_SHAREAWARE = &H4000
    Global Const ahtOFN_NOREADONLYRETURN = &H8000
    Global Const ahtOFN_NOTESTFILECREATE = &H10000
    Global Const ahtOFN_NONETWORKBUTTON = &H20000
    Global Const ahtOFN_NOLONGNAMES = &H40000
    New for Windows 95
    Global Const ahtOFN_EXPLORER = &H80000
    Global Const ahtOFN_NODEREFERENCELINKS = &H100000
    Global Const ahtOFN_LONGNAMES = &H200000






    Public Function BrowseFolder(szDialogTitle As String) As String
      Dim X 
    As Longbi As BROWSEINFOdwIList As Long
      Dim szPath 
    As StringwPos As Integer
      
        With bi
            
    .hOwner hWndAccessApp
            
    .lpszTitle szDialogTitle
            
    .ulFlags BIF_RETURNONLYFSDIRS
        End With
        
        dwIList 
    SHBrowseForFolder(bi)
        
    szPath Space$(512)
        
    SHGetPathFromIDList(ByVal dwIListByVal szPath)
        
        If 
    X Then
            wPos 
    InStr(szPathChr(0))
            
    BrowseFolder Left$(szPathwPos 1)
        Else
            
    BrowseFolder ""
        
    End If
    End Function 
    Put a button and a text box to return the FolderPath in it

    In the click event of the Button write
    PHP Code:
      Private Sub Befehl0_Click()
         
    yourTextBoxName BrowseFolder("Choose the folder")
      
    End Sub 
    Sorry for Spain in the EU

  3. #3
    Join Date
    Nov 2003
    Location
    Europe
    Posts
    369
    Quote Originally Posted by hammbakka
    Sorry for Spain in the EU
    Well, I'm nordic, just temporarily setting up some business/services in Spain before moving on out of EU... Hope whoever deserves it, wins the soccer cup :-)

    Thanks for the code, splendid, will try it asap :-)

    D.
    Win-XP pro, Access 2002, ADO 2.7, DAO 3.6. English versions of apps/OS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •