globetrot
09-20-2004, 03:02 AM
Im having a small problem when trying to backup my data to a floppy, I have an error trapping routine that only works once. The code is below;
Private Sub cmdQuit_Click()
On Error GoTo Err_Disk
Dim answer As String
Main:
answer = MsgBox("Your data is about to be backed up, Please insert a disk into drive A: and click OK to continue with the backup or cancel to exit the database", vbOKCancel, "Backup Data")
If answer = vbOK Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbltransaction", "A:\Transactiondata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblclients", "A:\Clientdata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblresourcetype", "A:\ResourceTypedata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbltransaction", "A:\Childdata.xls"
MsgBox "Backup is complete. Click OK"
Else
GoTo Exit_cmdQuit_Click
End If
Err_Disk:
MsgBox "Please insert a disk in drive A:, if you continue to get this message try inserting another disk", , "Disk Error"
GoTo Main
End If
Exit_cmdQuit_Click:
DoCmd.Quit
Exit Sub
End Sub
The code works fine the first time you dont insert a disk but when you do it the second time I get a Runtime Error 3436 saying unable to create file. It seems to me that when I access the drive without the disk in it the first time the error event occurs but when you do it again it doesnt?
Private Sub cmdQuit_Click()
On Error GoTo Err_Disk
Dim answer As String
Main:
answer = MsgBox("Your data is about to be backed up, Please insert a disk into drive A: and click OK to continue with the backup or cancel to exit the database", vbOKCancel, "Backup Data")
If answer = vbOK Then
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbltransaction", "A:\Transactiondata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblclients", "A:\Clientdata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tblresourcetype", "A:\ResourceTypedata.xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "tbltransaction", "A:\Childdata.xls"
MsgBox "Backup is complete. Click OK"
Else
GoTo Exit_cmdQuit_Click
End If
Err_Disk:
MsgBox "Please insert a disk in drive A:, if you continue to get this message try inserting another disk", , "Disk Error"
GoTo Main
End If
Exit_cmdQuit_Click:
DoCmd.Quit
Exit Sub
End Sub
The code works fine the first time you dont insert a disk but when you do it the second time I get a Runtime Error 3436 saying unable to create file. It seems to me that when I access the drive without the disk in it the first time the error event occurs but when you do it again it doesnt?