Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2007
    Location
    Austin Texas
    Posts
    7

    Unanswered: Common Dialog in Access 2000

    I am using the code posted in
    http://www.mvps.org/access/api/api0001.htm

    and it is working fine. I have spent hours trying to figure out how to have the defaultn view set to show file details in the Dialog box. My focus is mostly on the open function but again users need to see date created or be able to sort by name without changing the view.

    Any help would be very much appreciated.

    Using Access 2000 on XP machine

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Check out the common dialog boxes in the Code Bank. There's a few examples of different common dialog boxes in the one I posted on StoringOpeningFiles and there is one Georgev posted.

    http://www.dbforums.com/showpost.php...8&postcount=35 (note: you will need the Office Object Library 10 reference)

    and

    http://www.dbforums.com/showpost.php...8&postcount=40 (there are 2 different types of common dialog boxes examples (show files and show just folders), Office Object Library 10 reference is not needed)

    Once you pull up the common dialog box, you can change the view to show date, ascending, etc... I can't recall how you do it programmatically though but see the examples.
    Last edited by pkstormy; 11-19-07 at 23:48.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    The GetOpenFileName API Function doesn't contain the feature of changing the Lit View type within the dialog window. Do do that you will need to Hook the dialog window and tell the dialog to do that. A whole new nest of worms.

    It's much easier on the mind to eith leave things as they are or utilize a different file dialog system perhaps the FileSystemObject or the Explorer Dialog system. But....if you're bent on using the API unit (and there is nothing wrong with that) and you want to set the List Views to whatever you want, then go to this website. It shows you how. You will need to add a few more functions.

    .

    [/font]
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    CyberLynx - I've used the GetOpenFileName to change the List view with the Hook without any problems. I'm curious why you think it's a nest of worms.

    I personally prefer this verses the FSO.

    Are you referring to the IShellBrowser::BrowseObject or the Call Shell("Explorer """ & strDirectory & """", vbNormalFocus) ...
    regarding Explorer? I do like the shelling to explorer method.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Nov 2003
    Posts
    1,487
    Just an expression Paul. I have also used the hook and without problems...I simply meant that is more code to deal and if it's a simple matter of viewing the file details within a dialog box, then there are easier alternatives with less code and with perhaps a little more flexability.

    Alternative 1: Using MSO

    Remove all the comments from the code below and there really isn't much code.

    Code:
        ‘ Need ‘Microsoft Office 10.0 Object Library’ set in References 
         ‘ for this to work.  Place the code into the OnClick event of a
         ‘ Command Button or place it into a Function procedure.
         On Error GoTo dlg_Error
         Dim dlg As Object
         Dim vrtSelectedItem As Variant
      
         ' 1 is the File Open Dialog       -  msoFileDialogOpen
         ' 2 is the File SaveAs Dialog     -  msoFileDialogSaveAs
         ' 3 is the File Browser (Picker)  -  msoFileDialogFilePicker
         ' 4 is the Folder Browser (Picker)-  msoFileDialogFolderPicker
          Set dlg = Application.FileDialog(msoFileDialogFilePicker)
          With dlg
            ' Set the File Dialog Window Title
            .Title = "Select Student Photo..."
            ' Clear any File Dialog Filters
            .Filters.Clear
            ' Add a New File Dialog Filters. Filters don’t apply to a Folder Dialog
            .Filters.Add "Images", "*.bmp; *.gif; *.jpg; *.jpeg; *.wmf", 1
            .Filters.Add "All files", "*.*"
            ' Set the Name for the action button in our File Dialog
            .ButtonName = "Take Student"
            ' Turn OFF File multi Select. We don't need this now.
            .AllowMultiSelect = False
            ' Set the File Dialog window to show Thumbnamils
            .InitialView = msoFileDialogViewThumbnail
                ‘ All Available Views:
                      ‘ msoFileDialogViewDetails
                      ‘ msoFileDialogViewLargeIcons
                      ‘ msoFileDialogViewList
                      ‘ msoFileDialogViewPreview
                      ‘ msoFileDialogViewProperties
                      ‘ msoFileDialogViewSmallIcons
                      ‘ msoFileDialogViewThumbnail
                      ‘ msoFileDialogViewWebView
            ' Set folder in which the File Dialog will start from.
            .InitialFileName = CurDir
            ' If the Action button is selected and a file has indeed been
            ' selected then place the path & file name into the PhotoPath
            ' field on Form and set the Image Control (StudentPicture) to
            ' display it.
            If .show = -1 And Not IsNull(.SelectedItems) Then
               For Each vrtSelectedItem In .SelectedItems
                 Me.PhotoPath = vrtSelectedItem
                 Me.StudentPicture.Picture = Me.PhotoPath
               Next
            End If
          End With
      
      Exit_dlg_Error:
          Set dlg = Nothing   ' Free memory
          Exit Sub
      
      dlg_Error:
          MsgBox Error
          Resume Exit_dlg_Error

    Another alternative: The Explorer call Shell:

    Code:
     Sub OpenExplorer()
      Dim x As Variant
      Const msgTitle As String = "Open Explorer"
      Const cExplorerPath As String = "C:\WINDOWS\EXPLORER.EXE"
      Const cExplorerSwitches As String = " /n,/e"
      Const cFilePath As String = "YourFilePath"
      
      On Error GoTo Error_Handler
      
      If Dir(cExplorerPath, vbDirectory) = "" Then
         MsgBox "Explorer Path '" & cExplorerPath & "' could not be found.", vbCritical, msgTitle
         x = Shell(cExplorerPath, vbNormalFocus)
      ElseIf Dir(cFilePath, vbDirectory) = "" Then
         MsgBox "Path '" & cFilePath & "' could not be found.", vbCritical, msgTitle
         x = Shell(cExplorerPath, vbNormalFocus)
      Else
         x = Shell(cExplorerPath & cExplorerSwitches & "," & cFilePath, vbNormalFocus)
      End If
      
      Exit Sub
      
      Error_Handler:
         MsgBox "An error has occured trying to open Explorer", vbCritical, msgTitle
      End Sub
    Just less code Paul....that's all.

    I personally use the API 90% of the time since it doesn't require the hassel of ensuring References.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  6. #6
    Join Date
    Nov 2007
    Location
    Austin Texas
    Posts
    7
    Thanks for the feedback and help.

    I chose Alternative 1: Using MSO as I need the path and file information returned before opening. This option worked real nice, after I loaded 'Microsoft Office 11.0 Object Library’ .


    One follow-up question

    Do I need to make sure that other users who used the database have this Object Library loaded as well or will the Library now be part of the database ? (I will search for this answer in the forum)

    Thank you again for all of your input and help.

    DK

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I believe the Microsoft Office 11.0 Object Library is dependant upon Microsoft Office being installed. I don't recall if installing just Access installed this object library or not (or what other MS products do install it) but if a user doesn't have it installed, they will most likely get an error (or all the other references won't load if this one can't load). If they do have Office installed, then it shouldn't be an issue. You might also want to consider using an *.mde (compiled mdb) verses an mdb.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Nov 2003
    Posts
    1,487
    This is exactly why a lot of people prefer the API dialog version over the mso. All computers with the front end installed will need to make Reference to the Microsoft Office xx.x Object Library. This means everyones office system must be up to snuff. If your developing a package specificly for yourself or a single client then what the hell. I don't care where the package is going...when using moderately unique references can always be a pain (in my opinion).

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  9. #9
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

Posting Permissions

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