Access Attachment Dialog Window

断了今生、忘了曾经 提交于 2021-02-20 02:29:36

问题


I am trying to open the window pictured in the following link using a commmand button in a form. Is it possible that anyone can show me how to do that?

http://www.utteraccess.com/forum/Launching-Attachments-Dia-t1652872.html

Thank you in advance!


回答1:


I am not sure if you can call this specific dialog, but what you can do is use the generic FileDialog with the FilePicker option. Then save use that path to the file and copy the specific file to a shared location (probably somewhere where your backend is stored too). Then in your table, you save the path to that new location.

The use of the filedialog is explained in the help:

Sub Main()

    'Declare a variable as a FileDialog object.
    Dim fd As FileDialog

    'Create a FileDialog object as a File Picker dialog box.
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    'Declare a variable to contain the path
    'of each selected item. Even though the path is aString,
    'the variable must be a Variant because For Each...Next
    'routines only work with Variants and Objects.
    Dim vrtSelectedItem As Variant

    'Use a With...End With block to reference the FileDialog object.
    With fd

        'Use the Show method to display the File Picker dialog box and return the user's action.
        'The user pressed the button.
        If .Show = -1 Then

            'Step through each string in the FileDialogSelectedItems collection.
            For Each vrtSelectedItem In .SelectedItems

                'vrtSelectedItem is aString that contains the path of each selected item.
                'You can use any file I/O functions that you want to work with this path.
                'This example displays the path in a message box.
                MsgBox "The path is: " & vrtSelectedItem

            Next vrtSelectedItem
        'The user pressed Cancel.
        Else
        End If
    End With

    'Set the object variable to Nothing.
    Set fd = Nothing

End Sub 

And through Google, I came across this (old) topic giving even more reasons not to use the attachement type in your table (update, insert,... queries won't work that easily i.e.).

Since I follow David.W.Fenton's comment on my answer, I would also recommend reading the following topic on SO. Especially the answer by Mitch Weath gives some extra information about using the Win32 API for the Open file dialog.



来源:https://stackoverflow.com/questions/5994118/access-attachment-dialog-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!