Common Dialog in Access 2000

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • deko

    Common Dialog in Access 2000

    What is the best way to get a Common Dialog in Access 2000 Standard Edition?

    Microsoft suggests this:

    Private Declare Function GetOpenFileName Lib "comdlg32.d ll" Alias _
    "GetOpenFileNam eA" (pOpenfilename As OPENFILENAME) As Long

    Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilt er As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    End Type

    (See: http://support.microsoft.com/default...b;en-us;303066)

    In Access 2003 I was using this:

    Private Sub Browse(strTag As String)
    Dim dDialog As Office.FileDial og
    Dim varDir As Variant
    Set dDialog = Application.Fil eDialog(msoFile DialogFolderPic ker)
    dDialog.AllowMu ltiSelect = False
    dDialog.Title = " Select Directory"
    If dDialog.Show = True Then
    For Each varDir In dDialog.Selecte dItems
    Me!txtPath = varDir
    Next
    End If
    End Sub

    Do I need MS's private function?

    Thanks in advance.


  • Wayne Morgan

    #2
    Re: Common Dialog in Access 2000

    You will also find an example for that here:


    The advantage of the longer method is that it calls the Windows API and so
    should always work. Calling the Office Dialog could cause a problem if you
    have mixed versions of Office. As you may have noticed, in order to get the
    Office Dialog to work you had to set a reference to "Microsoft Office 11.0
    Object Library". This is version specific. Moving up a version usually isn't
    a problem, but if you try to open your file on an older version of Access
    that supports your file format, this is likely to break and you'll have to
    go into the references dialog to manually set it to the older library. Also,
    if you are creating MDE files, you'll have to reset this for the version of
    Access the MDE is going to be created in, before creating the MDE. This is
    one of the reasons and MDE has to be created on the same version of Access
    that it is going to be run on.

    --
    Wayne Morgan
    MS Access MVP


    "deko" <deko@hotmail.c om> wrote in message
    news:9PFTd.7135 $OU1.4189@newss vr21.news.prodi gy.com...[color=blue]
    > What is the best way to get a Common Dialog in Access 2000 Standard
    > Edition?
    >
    > Microsoft suggests this:
    >
    > Private Declare Function GetOpenFileName Lib "comdlg32.d ll" Alias _
    > "GetOpenFileNam eA" (pOpenfilename As OPENFILENAME) As Long
    >
    > Private Type OPENFILENAME
    > lStructSize As Long
    > hwndOwner As Long
    > hInstance As Long
    > lpstrFilter As String
    > lpstrCustomFilt er As String
    > nMaxCustFilter As Long
    > nFilterIndex As Long
    > lpstrFile As String
    > nMaxFile As Long
    > lpstrFileTitle As String
    > nMaxFileTitle As Long
    > lpstrInitialDir As String
    > lpstrTitle As String
    > flags As Long
    > nFileOffset As Integer
    > nFileExtension As Integer
    > lpstrDefExt As String
    > lCustData As Long
    > lpfnHook As Long
    > lpTemplateName As String
    > End Type
    >
    > (See: http://support.microsoft.com/default...b;en-us;303066)
    >
    > In Access 2003 I was using this:
    >
    > Private Sub Browse(strTag As String)
    > Dim dDialog As Office.FileDial og
    > Dim varDir As Variant
    > Set dDialog = Application.Fil eDialog(msoFile DialogFolderPic ker)
    > dDialog.AllowMu ltiSelect = False
    > dDialog.Title = " Select Directory"
    > If dDialog.Show = True Then
    > For Each varDir In dDialog.Selecte dItems
    > Me!txtPath = varDir
    > Next
    > End If
    > End Sub
    >
    > Do I need MS's private function?
    >
    > Thanks in advance.
    >
    >[/color]


    Comment

    • DFS

      #3
      Re: Common Dialog in Access 2000

      Wayne Morgan wrote:[color=blue]
      > You will also find an example for that here:
      > http://www.mvps.org/access/api/api0001.htm
      >
      > The advantage of the longer method is that it calls the Windows API
      > and so should always work. Calling the Office Dialog could cause a
      > problem if you have mixed versions of Office. As you may have
      > noticed, in order to get the Office Dialog to work you had to set a
      > reference to "Microsoft Office 11.0 Object Library". This is version
      > specific. Moving up a version usually isn't a problem, but if you try
      > to open your file on an older version of Access that supports your
      > file format, this is likely to break and you'll have to go into the
      > references dialog to manually set it to the older library. Also, if
      > you are creating MDE files, you'll have to reset this for the version
      > of Access the MDE is going to be created in, before creating the MDE.[/color]
      [color=blue]
      > This is one of the reasons and MDE has to be created on the same
      > version of Access that it is going to be run on.[/color]

      Doesn't have to be. I created and delivered an Access 2000 .mde that ran
      fine on Access 2003 when my clients upgraded.



      [color=blue]
      > "deko" <deko@hotmail.c om> wrote in message
      > news:9PFTd.7135 $OU1.4189@newss vr21.news.prodi gy.com...[color=green]
      >> What is the best way to get a Common Dialog in Access 2000 Standard
      >> Edition?
      >>
      >> Microsoft suggests this:
      >>
      >> Private Declare Function GetOpenFileName Lib "comdlg32.d ll" Alias _
      >> "GetOpenFileNam eA" (pOpenfilename As OPENFILENAME) As Long
      >>
      >> Private Type OPENFILENAME
      >> lStructSize As Long
      >> hwndOwner As Long
      >> hInstance As Long
      >> lpstrFilter As String
      >> lpstrCustomFilt er As String
      >> nMaxCustFilter As Long
      >> nFilterIndex As Long
      >> lpstrFile As String
      >> nMaxFile As Long
      >> lpstrFileTitle As String
      >> nMaxFileTitle As Long
      >> lpstrInitialDir As String
      >> lpstrTitle As String
      >> flags As Long
      >> nFileOffset As Integer
      >> nFileExtension As Integer
      >> lpstrDefExt As String
      >> lCustData As Long
      >> lpfnHook As Long
      >> lpTemplateName As String
      >> End Type
      >>
      >> (See: http://support.microsoft.com/default...b;en-us;303066)
      >>
      >> In Access 2003 I was using this:
      >>
      >> Private Sub Browse(strTag As String)
      >> Dim dDialog As Office.FileDial og
      >> Dim varDir As Variant
      >> Set dDialog = Application.Fil eDialog(msoFile DialogFolderPic ker)
      >> dDialog.AllowMu ltiSelect = False
      >> dDialog.Title = " Select Directory"
      >> If dDialog.Show = True Then
      >> For Each varDir In dDialog.Selecte dItems
      >> Me!txtPath = varDir
      >> Next
      >> End If
      >> End Sub
      >>
      >> Do I need MS's private function?
      >>
      >> Thanks in advance.[/color][/color]


      Comment

      • Tim Marshall

        #4
        Re: Common Dialog in Access 2000

        Wayne Morgan wrote:[color=blue]
        > You will also find an example for that here:
        > http://www.mvps.org/access/api/api0001.htm
        >
        > The advantage of the longer method is that it calls the Windows API and so
        > should always work.[/color]

        Indeed it does. I used the above code in Access 97 and it ported to
        Access 2003 with no difficulty whatsoever, no changes or tweaking required.
        --
        Tim http://www.ucs.mun.ca/~tmarshal/
        ^o<
        /#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
        /^^ "What's UP, Dittoooooo?" - Ditto

        Comment

        • Wayne Morgan

          #5
          Re: Common Dialog in Access 2000

          Thanks, again though you were moving up to a newer version. Also, were you
          using the runtime version of Access or the full version on the clients'
          machines?

          --
          Wayne Morgan
          MS Access MVP


          "DFS" <nospam@DFS.com > wrote in message
          news:apHTd.1010 7$U07.4278@fe02 .lga...[color=blue]
          >
          > Doesn't have to be. I created and delivered an Access 2000 .mde that ran
          > fine on Access 2003 when my clients upgraded.[/color]


          Comment

          • DFS

            #6
            Re: Common Dialog in Access 2000

            Wayne Morgan wrote:[color=blue]
            > Thanks, again though you were moving up to a newer version. Also,
            > were you using the runtime version of Access or the full version on
            > the clients' machines?[/color]

            Full version. In fact, I believe the default file format is Access 2000
            when Access 2003 is installed. I know I've seen that on several machines.
            Maybe that's only upgrades?

            [color=blue]
            >
            >
            > "DFS" <nospam@DFS.com > wrote in message
            > news:apHTd.1010 7$U07.4278@fe02 .lga...[color=green]
            >>
            >> Doesn't have to be. I created and delivered an Access 2000 .mde
            >> that ran fine on Access 2003 when my clients upgraded.[/color][/color]


            Comment

            • deko

              #7
              Re: Common Dialog in Access 2000

              > The advantage of the longer method is that it calls the Windows API and so[color=blue]
              > should always work. Calling the Office Dialog could cause a problem if you
              > have mixed versions of Office. As you may have noticed, in order to get[/color]
              the[color=blue]
              > Office Dialog to work you had to set a reference to "Microsoft Office 11.0
              > Object Library". This is version specific. Moving up a version usually[/color]
              isn't[color=blue]
              > a problem, but if you try to open your file on an older version of Access
              > that supports your file format, this is likely to break and you'll have to
              > go into the references dialog to manually set it to the older library.[/color]
              Also,[color=blue]
              > if you are creating MDE files, you'll have to reset this for the version[/color]
              of[color=blue]
              > Access the MDE is going to be created in, before creating the MDE. This is
              > one of the reasons and MDE has to be created on the same version of Access
              > that it is going to be run on.[/color]

              I think the Office Dialog is clearly better. Sort of like .NET - if MS
              wants to abstract the API and make it easier for me, great. The more
              productive and less arcane this business is the happier I am. But from a
              manager's perspective, the API is clearly a better solution. I guess it
              depends on how much control you have over your environment (which is usually
              not much).

              As an aside, you mention that "Moving up a version usually isn't a
              problem..." I assume this the case for other references as well - e.g.
              Excel, Internet Controls, Scripting Runtime. I'm thinking about my early
              bound automation code and know from experience the unpredictable results
              caused by broken references.


              Comment

              • Wayne Morgan

                #8
                Re: Common Dialog in Access 2000

                You're correct about the default file version, it is the 2000 file version
                for Access 2000, 2002, and 2003. I believe that the problem comes in with
                the "Microsoft Access x.x Object Library" and the runtime version. The
                runtime is more restrictive in what it will let you do and I suspect that it
                won't let the object library reference upgrade itself. I would have to
                reinstall the older version to test this though. It should be testable by
                creating and MDE in Access 2000 and opening it with Access 2003 using the
                /runtime switch.

                --
                Wayne Morgan
                MS Access MVP


                "DFS" <nospam@DFS.com > wrote in message
                news:52RTd.1032 2$jZ6.5068@fe02 .lga...[color=blue]
                >
                > Full version. In fact, I believe the default file format is Access 2000
                > when Access 2003 is installed. I know I've seen that on several machines.
                > Maybe that's only upgrades?[/color]


                Comment

                • Wayne Morgan

                  #9
                  Re: Common Dialog in Access 2000

                  Yes, I've run across this with Excel also. I can take a '97 Excel spread
                  sheet to a machine with Excel 2003 installed. If I open the spreadsheet on
                  that machine then take it back to the machine with Excel 97, the code will
                  error out until I reset the object libraries to the '97 versions. The DAO
                  library usually stays put (the newer machine has the old library available),
                  it's the Excel library that is usually the problem.

                  --
                  Wayne Morgan
                  MS Access MVP


                  "deko" <deko@hotmail.c om> wrote in message
                  news:1RTTd.7368 $OU1.1794@newss vr21.news.prodi gy.com...[color=blue]
                  >
                  > As an aside, you mention that "Moving up a version usually isn't a
                  > problem..." I assume this the case for other references as well - e.g.
                  > Excel, Internet Controls, Scripting Runtime. I'm thinking about my early
                  > bound automation code and know from experience the unpredictable results
                  > caused by broken references.
                  >
                  >[/color]


                  Comment

                  Working...