Office中国论坛/Access中国论坛

标题: 如何调用另一窗体的命令按钮 [打印本页]

作者: guizhi    时间: 2005-5-12 21:29
标题: 如何调用另一窗体的命令按钮
[attach]10411[/attach]
如何实现,打开“打开并刷新窗体”,点击“打开并刷新数据透视表”按钮后,打开“透视表”窗体并能自动点击“编辑数据透视表对象”按钮。
作者: Trynew    时间: 2005-5-12 22:42
[attach]10413[/attach]

两种方法,分别利用Form_Load和Form_Timer在另一窗体运行程序、执行命令:

窗体1代码:

Private Sub Command1_Click()
DoCmd.OpenForm "透视表", acNormal, "", "", , acNormal
Forms("透视表").TimerInterval = 10
End Sub

Private Sub 命令0_Click()
DoCmd.OpenForm "透视表", acNormal, "", "", , acNormal, "Edit"
End Sub

窗体2代码:

Private Sub btnEdit_Click()
On Error GoTo btnEdit_Err
    Me!PivotTable.Verb = acOLEVerbOpen
    Me!PivotTable.Action = acOLEActivate
btnEdit_Exit:
    Exit Sub
btnEdit_Err:
    MsgBox Err.Description
    Resume btnEdit_Exit
End Sub

Private Sub Form_Load()
    If Me.OpenArgs = "Edit" Then btnEdit_Click
End Sub

Private Sub Form_Timer()
    btnEdit_Click
    Me.TimerInterval = 0
End Sub

作者: guizhi    时间: 2005-5-14 00:27
谢谢Trynew版主,我想再问一下 :关闭EXCEL之后自动关闭“透视表”窗体返回“打开并刷新窗体”如何实现?




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3