北京 | 上海 | 天津 | 重庆 | 广州 | 深圳 | 珠海 | 汕头 | 佛山 | 中山 | 东莞 | 南京 | 苏州 | 无锡 | 常州 | 南通 | 扬州 | 徐州 | 杭州 | 温州 | 宁波 | 台州 | 福州 | 厦门 | 泉州 | 龙岩 | 合肥 | 芜湖 | 成都 | 遂宁 | 长沙 | 株洲 | 湘潭 | 武汉 | 南昌 | 济南 | 青岛 | 烟台 | 潍坊 | 淄博 | 济宁 | 太原 | 郑州 | 石家庄 | 保定 | 唐山 | 西安 | 大连 | 沈阳 | 长春 | 昆明 | 兰州 | 哈尔滨 | 佳木斯 | 南宁 | 桂林 | 海口 | 贵阳 | 西宁 | 乌鲁木齐 | 包头 |
Option Compare Database
Private Function HandleButtonClick(intbtn As Integer)
' 处理按钮click事件
Const conCmdGotoSwitchboard = 1
Const conCmdNewForm = 2
Const conCmdOpenReport = 3
Const conCmdExitApplication = 4
Const conCmdRunMacro = 8
Const conCmdRunCode = 9
Const conCmdOpenPage = 10
Const conErrDoCmdCancelled = 2501
Dim rs As ADODB.Recordset
Dim strSQL As String
On Error GoTo HandleButtonClick_Err
Set rs = CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM [Switchboard Items]"
strSQL = strSQL & "WHERE [SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intbtn
Set rs = GetRs(strSQL)
If (rs.EOF) Then
MsgBox "读取 Switchboard Items 表时出错。"
rs.Close
Set rs = Nothing
Exit Function
End If
Select Case rs![Command] ' 进入另一个切换面板
Case conCmdGotoSwitchboard
Me.Filter = "[ItemNumber] = 0 AND [SwitchboardID]=" & rs![Argument]
' 打 开一个新窗体
Case conCmdNewForm
DoCmd.OpenForm rs![Argument]
' 打开报表
Case conCmdOpenReport
DoCmd.OpenReport rs![Argument], acPreview
' 退出应用程序
Case conCmdExitApplication
CloseCurrentDatabase
' 运行宏.
Case conCmdRunMacro
DoCmd.RunMacro rs![Argument]
' 运行代码.
Case conCmdRunCode
Application.Run rs![Argument]
' 打开一个数据存取页面
Case conCmdOpenPage
DoCmd.OpenDataAccessPage rs![Argument]
' 未定义的选项
Case Else
MsgBox "未知选项"
End Select
' Close the recordset and the database.
rs.Close
HandleButtonClick_Exit:
On Error Resume Next
Set rs = Nothing
Exit Function
HandleButtonClick_Err:
If (Err = conErrDoCmdCancelled) Then
Resume Next
Else
MsgBox "执行命令时出错。", vbCritical
Resume HandleButtonClick_Exit
End If
End Function