用select case语句:
Private Sub 选择_AfterUpdate()
Dim fz As Object
Dim 选择 As Integer
Me.Requery
Select Case Me.选择
Case "导出费用确认单"
If MsgBox("是否确定导出费用确认单", Me.选择 = "导出费用确认单" And vbQuestion + vbOKCancel = vb0k) Then
Me.Requery
DoCmd.SetWarnings False
DoCmd.OpenQuery "费用单里的内容"
DoCmd.OpenQuery "查询10"
Set fz = CreateObject("Scripting.FileSystemObject")
fz.Copyfile CurrentProject.Path & "\报价表和费用确认单.xls", CurrentProject.Path & "\ceshi\报价表和费用确认单.xls"
Name CurrentProject.Path & "\ceshi\报价表和费用确认单.xls" As CurrentProject.Path & "\ceshi\" & Format(Now(), "yyyymmddhhmmss") & ".xls"
MsgBox ("报关单已导出到“ceshi”文件夹内,请查看")
DoCmd.OpenQuery "查询3"
Shell "explorer.exe " & CurrentProject.Path & "\ceshi\", vbNormalFocus
End If
Case "导出预配仓单"
If MsgBox("是否确定导出预配仓单", Me.选择 = "导出预配仓单" And vbQuestion + vbOKCancel = vb0k) Then
Me.Requery
DoCmd.SetWarnings False
DoCmd.OpenQuery "查询1"
DoCmd.OpenQuery "查询2"
Set fz = CreateObject("Scripting.FileSystemObject")
fz.Copyfile CurrentProject.Path & "\三联单舱单数据.xls", CurrentProject.Path & "\三联单舱单数据\三联单舱单数据.xls"
Name CurrentProject.Path & "\三联单舱单数据\三联单舱单数据.xls" As CurrentProject.Path & "\三联单舱单数据\" & Format(Now(), "yyyymmddhhmmss") & ".xls"
MsgBox ("三联单舱单数据已导出到“三联单舱单数据”文件夹内,请查看")
DoCmd.OpenQuery "查询3"
Shell "explorer.exe " & CurrentProject.Path & "\三联单舱单数据\", vbNormalFocus
End If
End Select
End Sub