dannyherrera
Programmer
i want to be able to save a .doc file to one of my tables. i have a quote system where the user can export a quote to word and update it. i want them to be able to upload the new revised quote file to the table. i have set up the table to accespt ole objects and have created a form that allows the user to select to file to upload from their computer. the following is the code i have so far but doesnt work.
Code:
Private Sub cmdSaveUpload_Click()
On Error GoTo Err_cmdSaveUpload_Click
<this line of code gives the error: "The command or action InsertObject isnt available right now.">
'DoCmd.RunCommand acCmdInsertObject
<this line of code gives the error: "You cannot import this file.">
DoCmd.TransferText acImportDelim, "Revised Quote", "tblUploadedQuotes", Me.txtUpload.Value
Exit_cmdSaveUpload_Click:
Exit Sub
Err_cmdSaveUpload_Click:
MsgBox Err.Description
Resume Exit_cmdSaveUpload_Click
End Sub
Private Sub cmdUpload_Click()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Allow the user to select multiple files.
.AllowMultiSelect = False
'Use the Show method to display the File Picker dialog box and return the user's action.
'If the user presses the action button...
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String 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 simply displays the path in a message box.
Me.txtUpload = vrtSelectedItem
Next
'If the user presses Cancel...
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub