|
公用模块用Sub
Sub 备份数据()
On Error GoTo 备份数据_Err
If (DCount("[学号]", "成绩表") < 1) Then
Beep
MsgBox "成绩表没有数据,备份中止", vbInformation, "备份信息"
Exit Sub
End If
If (DCount("[学号]", "学生表") < 1) Then
Beep
MsgBox "学生表没有数据,备份中止", vbInformation, "备份信息"
Exit Sub
End If
DoCmd.OutputTo acTable, "成绩表", "MicrosoftExcelBiff8(*.xls)", "d:\成绩表", False, "", 0
DoCmd.OutputTo acTable, "学生表", "MicrosoftExcelBiff8(*.xls)", "d:\学生表", False, "", 0
MsgBox "数据已备份", vbInformation, "备份信息"
备份数据_Exit:
Exit Sub
备份数据_Err:
MsgBox Error$
Resume 备份数据_Exit
End Sub
窗体按钮事件程序:
Private Sub Command0_Click()
备份数据
End Sub |
|