子窗体打开时如何冻结父窗体 [英] How to freeze Parent Form while Child Form is open

查看:92
本文介绍了子窗体打开时如何冻结父窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的情况是,在某些情况下,我需要打开另一个表单并保持该表单的焦点(modal = true),当它们不存在并关闭时,将使用可能的数据刷新父表单上的控件可能已经改变了.

I have a situation where, in certain circumstances, i need to open another form and keep that form focused (modal = true) and when they are dont and it closes, a control on the parent form is refreshed with possible data that might have changed.

最初,我有一种方法可以在子窗体打开时使用DoEvents,但是它会导致多个子窗体对于数据输入/编辑不可用(它们在窗体级别没有数据绑定).

Originally i had a method that would DoEvents while the child form was open but it cause several of the child forms to be unusable (they werent databound at the form level) for data-entry/edits.

Public Sub ShowForm(par As Form, nm As String, _
                    Optional whr As String = "", _
                    Optional args As String = "", _
                    Optional mode As AcFormOpenDataMode = acFormPropertySettings)
    DoCmd.OpenForm nm, acNormal, , whr, mode, , args

    While IsOpen(nm)
        DoEvents
    Wend
End Sub

为了让我能够始终使用子窗体,我不得不注释掉While...Wend循环.

In order for me to get the Child Forms to be usable consistently, i had to comment out the While...Wend loop.

我是否可以在此方法内部或调用控件的OnClick中使用另一种逻辑模式,以便当他们关闭子窗体时,可以在关闭子窗体后执行代码?

Is there another logic pattern i could use either inside this method or the OnClick of the calling control, so that way when they close the Child Form i could have code execute after the closing of the childform?

推荐答案

这是我最初的问题中方法的最终形式:按我想要的方式工作(现在;)),@@ Remou& @ mwolfe02.

Here is the final form of the method in my original question: Works just as i wanted (for now ;) ), thanx to @Remou & @mwolfe02.

'@frm - String value, Name of the form to Open
Public Sub OpenForm(frm As String, _
                    Optional vw As AcFormView = acNormal, _
                    Optional whr As String = "", _
                    Optional mode As AcFormOpenDataMode = acFormPropertySettings, _
                    Optional args As String = "")
    If FormExists(frm) Then
        DoCmd.OpenForm frm, vw, , whr, mode, acDialog, args
    Else
        RaiseError "Form ( " & frm & " ) does not exist!" & vbCrLf & vbCrLf & _
                    "Alert your IT Support for further assistance."
    End If
End Sub

这篇关于子窗体打开时如何冻结父窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆