[AccessD] WindowsXP not recognising api Call

connie.kamrowski at agric.nsw.gov.au connie.kamrowski at agric.nsw.gov.au
Tue Jul 20 20:25:33 CDT 2004


Ok further to last week I have been trying to find the problem with my
inherited app. The api call works fine on windows98 and when taken to
windows XP machines does not work.
It throws no errors just does not open the Windows Open Save dialog box.
The code is word for word to the Getz API call but when the XP machine
reaches the
If OpenFile Then
        fResult = adh_apiGetOpenFileName(OFN)
    Else
        fResult = adh_apiGetSaveFileName(OFN)
    End If

It does not open the dialogue box. Running the same code side by side on
the win98 machine I get the popup box every time. I have run a reference
checker and it says all references are OK.
The code is below if that helps.

Connie Kamrowski

Analyst/Programmer
Information Technology
NSW Department of Primary Industries
Orange

Ph: 02 6391 3250
Fax:02 6391 3290

Function adhCommonFileOpenSave( _
 Optional ByRef Flags As Variant, _
 Optional ByVal InitialDir As Variant, _
 Optional ByVal Filter As Variant, _
 Optional ByVal FilterIndex As Variant, _
 Optional ByVal DefaultExt As Variant, _
 Optional ByVal FileName As Variant, _
 Optional ByVal DialogTitle As Variant, _
 Optional ByVal hwnd As Variant, _
 Optional ByVal OpenFile As Variant) As Variant

    ' This is the entry point you'll use to call the common
    ' file open/save dialog. The parameters are listed
    ' below, and all are optional.
    '
    ' From Access 97 Developer's Handbook
    ' by Litwin, Getz and Gilbert. (Sybex)
    ' Copyright 1997. All Rights Reserved.
    '
    ' In:
    '    Flags: one or more of the adhOFN_* constants, OR'd together.
    '    InitialDir: the directory in which to first look
    '    Filter: a set of file filters, set up by calling
    '            AddFilterItem.  See examples.
    '    FilterIndex: 1-based integer indicating which filter
    '            set to use, by default (1 if unspecified)
    '    DefaultExt: Extension to use if the user doesn't enter one.
    '            Only useful on file saves.
    '    FileName: Default value for the file name text box.
    '    DialogTitle: Title for the dialog.
    '    OpenFile: Boolean(True=Open File/False=Save As)
    ' Out:
    '    Return Value: Either Null or the selected filename

    Dim OFN As tagOPENFILENAME
    Dim strFileName As String
    Dim strFileTitle As String
    Dim fResult As Boolean

    ' Give the dialog a caption title.
    'If IsMissing(InitialDir) Then InitialDir = ""
    If IsMissing(InitialDir) Then
        InitialDir = CurDir
    Else
        If Dir(InitialDir, vbDirectory) = "" Then InitialDir = CurDir
    End If
    If IsMissing(Filter) Then Filter = ""
    If IsMissing(FilterIndex) Then FilterIndex = 1
    If IsMissing(Flags) Then Flags = 0&
    If IsMissing(DefaultExt) Then DefaultExt = ""
    If IsMissing(FileName) Then FileName = ""
    If IsMissing(DialogTitle) Then DialogTitle = ""
    If IsMissing(hwnd) Then hwnd = Application.hWndAccessApp
    If IsMissing(OpenFile) Then OpenFile = True

    ' Allocate string space for the returned strings.
    strFileName = Left(FileName & String(256, 0), 256)
    strFileTitle = String(256, 0)

    ' Set up the data structure before you call the function
    With OFN
        .lStructSize = Len(OFN)
        .hwndOwner = hwnd
        .strFilter = Filter
        .nFilterIndex = FilterIndex
        .strFile = strFileName
        .nMaxFile = Len(strFileName)
        .strFileTitle = strFileTitle
        .nMaxFileTitle = Len(strFileTitle)
        .strTitle = DialogTitle
        .Flags = Flags
        .strDefExt = DefaultExt
        '.strInitialDir = CurDir
        .strInitialDir = InitialDir

        ' Didn't think most people would want to deal with
        ' these options.
        .hInstance = 0
        .strCustomFilter = ""
        .nMaxCustFilter = 0
        .lpfnHook = 0
    End With

    ' This will pass the desired data structure to the
    ' Windows API, which will in turn it uses to display
    ' the Open/Save As Dialog.

    If OpenFile Then
        fResult = adh_apiGetOpenFileName(OFN)
    Else
        fResult = adh_apiGetSaveFileName(OFN)
    End If

    ' The function call filled in the strFileTitle member
    ' of the structure. You'll have to write special code
    ' to retrieve that if you're interested.

    If fResult Then
        ' You might care to check the Flags member of the
        ' structure to get information about the chosen file.
        ' In this example, if you bothered to pass in a
        ' value for Flags, we'll fill it in with the outgoing
        ' Flags value.
        If Not IsMissing(Flags) Then Flags = OFN.Flags
        adhCommonFileOpenSave = adhTrimNull(OFN.strFile)
        msgbox adhCommonFileOpenSave
    Else
        adhCommonFileOpenSave = Null
    End If
End Function


This message is intended for the addressee named and may contain
confidential information. If you are not the intended recipient or received
it in error, please delete the message and notify sender. Views expressed
are those of the individual sender and are not necessarily the views of
their organisation.





More information about the AccessD mailing list