Article ID: 150210
Article Last Modified on 7/16/2004
ShowModalForm Form1The subroutine ShowModalForm is shown below, and can be placed in a Form or standard code module:
Public Sub ShowModalForm(frmTarget As Form)
Dim ofrm As Object
'Disable all the forms
For Each ofrm In Forms
ofrm.Enabled = False
Next ofrm
'Now show the target form non-modal
frmTarget.Show
'If the frmTarget was disabled by the loop above
'make sure it is now enabled
frmTarget.Enabled = True
'Sit in a loop until the target form is dismissed
Do While frmTarget.Visible = True
DoEvents
Loop
'We have left the loop, so the dialog has been dismissed
'Now Enable the forms, and exit the procedure
For Each ofrm In Forms
ofrm.Enabled = True
Next ofrm
End Sub
Form2.Show vbModal
ShowModalForm Form2
Additional query words: kbVBp400bug kbVBp600fix kbVBp kbdsd kbDSupport kbNoKeyWord
Keywords: kbbug kbfix kbvbp600fix KB150210