Here is what I’m trying to do, basically just save the current db to the a: drive so that it can be carried around to different pcs:
Sub saveUpdateFile()
On Error GoTo HandleError
Dim strSaveLocation As String
Dim strTemp As String
Dim db As Database
strSaveLocation = InputBox(“Please enter the letter of the drive where you wish to save the update file:”, _
“Save Update File”, “A:”)
If Right(strSaveLocation, 1) “” Then
strSaveLocation = strSaveLocation & “”
End If
If Mid$(strSaveLocation, 2, 1) “:” Then
strTemp = Left$(strSaveLocation, 1) & “:”
strSaveLocation = Right$(strSaveLocation, Len(strSaveLocation) – 1)
strSaveLocation = strTemp & strSaveLocation
End If
Set db = CurrentDb()
FileCopy db.Name, strSaveLocation & “UserUpdate.mdb”
Exit Sub
HandleError:
Select Case Err.Number
Case Else
MsgBox Err.Number & ” ” & Err.Description, , “Save File Error”
End Select
End Sub
The problem with this code is that it generates Error 70, permission denied, when trying to copy the current database to a floppy.
Normally, I would just move on & try something else, but what confuses me is that the following code DOES work properly. And if this code works, why won’t the above?
With objOutlookMsg
Set objOutlookAttach = .Attachments.Add(db.Name)
.Subject = strSubject
.Body = strBody
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Display
End With
Note that to attach the current db to an email, all I have to do is reference it by it’s full name (path & name). So if I can attach it to an email, does anyone know why I’m unable to copy the exact same db to a disk? Does it have something to do with the file being open, and if so, why would it work to copy it as an attachment but not copy it as a file?
Thanks in advance for your help,
Cecilia 🙂