I am trying to setup a MS Access DB in server side, users can attach (hyperlink) his/her local files to DB that all users can see files, so it should upload selected user's file from his/her computer to server and server change it to a hyperlink from current DB path. I've found and change this code to do this by open file dialog to select file ( it's uploading file to "FILES" folder in DB path ) and then open hyperlink dialog to select file from "Files" folder in DB path.i want remove 2nd dialog box (hyperlink) and user just pick a file from his/her computer and hyperlink will build and add pragmatically to desired object in form.
anyone can hand me? Thank you very much
Code:
Private Sub cmdbtnupload_Click()
Dim fDialog As Office.FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim varFile As Variant
' Set up the File Dialog. '
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
'fd.InitialFileName = Application.CurrentProject.Path
fd.InitialFileName = "c:\"
With fDialog
' Allow user to make multiple selections in dialog box '
.AllowMultiSelect = False
' Set the title of the dialog box. '
.Title = "Please select a File to Attache"
' Clear out the current filters, and add our own.'
.Filters.Clear
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the '
' user picked at least one file. If the .Show method returns '
' False, the user clicked Cancel. '
If .Show = True Then
' This section takes the selected image and copy's it to the generated path'
' the string takes the file location, navigates to the image folder, uses the combo box selection to decide the file category, then uses the name from the filedialog to finish the path'
FileCopy .SelectedItems(1), Application.CurrentProject.Path & "\Files\" & Combo153 & "\" & Dir(Trim(.SelectedItems.Item(1)))
Me.attachmentpath.SetFocus
RunCommand acCmdInsertHyperlink
Else
End If
End With
End Sub
Comment