@Aflatoon:
Thank you very much, I changed the code accordingly and it does what I intended it to (see, code below).
1) Why doesn't it work if the form is modeless?
2) If modeless is a requirement, how will you adapt the code?
I have the following code in the userform module "frmEmailAlert" as attached:
Option Explicit
Public bOK As Boolean
Public bCancel As Boolean
Private Sub cmdCancel_Click()
bCancel = True
End Sub
Private Sub UserForm_Activate()
Dim dTimer As Double
dTimer = Timer
Do While Timer < dTimer + 5 And Not bOK And Not bCancel
DoEvents
Loop
If bOK = False And bCancel = False Then
bOK = True
End If
Me.Hide
End Sub
Private Sub cmdOK_Click()
bOK = True
End Sub
The following code is in a regular module "MainCodeModule" as attached:
Option Explicit
Sub MainCode()
frmEmailAlert.Show
If frmEmailAlert.bOK Then
MsgBox "OK Selected"
End If
If frmEmailAlert.bCancel Then
MsgBox "Cancel Selected"
End If
Unload frmEmailAlert
MsgBox "You are now here"
End Sub
Regards,
vanhunk