3

Access プロジェクトに次の VBA があります。

DoCmd.OpenForm "Importing"
' Some CPU-intensive code

問題は、集中的な部分が完了するまで白い画面が表示されることです。

残りのコードを実行する前に、フォームが開くまで待つにはどうすればよいですか?

4

2 に答える 2

4

Sorry for the question guys, I've just found the answer (one of them cases of Googling for a while, posting to SO, and finding the answer right after):

DoCmd.OpenForm "Importing"
DoEvents
' Some CPU-intensive code
于 2012-10-01T16:15:48.830 に答える
2

完全を期すために、次の関数を使用することもできます。どこから入手したか覚えていませんが、書いていません。

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
' Use form name according to Access, not VBA.
' Only works for Access
    Dim oAccessObject As AccessObject

    Set oAccessObject = CurrentProject.AllForms(strFormName)
    If oAccessObject.IsLoaded Then
        If oAccessObject.CurrentView <> acCurViewDesign Then
            IsLoaded = True
        End If
    End If

End Function

次に、コードで:

 DoCmd.OpenForm "Importing"
    Do While Not ISLoaded("Importing")
        DoEvents
    Loop
于 2012-10-01T16:26:46.853 に答える