FORM ACTIVATE EVENT

G

Glint

Hi Guys,
I am sorry to re-post this problem I have but I have not been able to find
an explanation. It is this: I want a user to be aware that a message has
arrived for him whenever he gets to the switchboard and then take him
directly to the message by opening the appropriate form.
The problem I have is that the code appears to execute more than one time as
the msgbox in the code pops up twice or more. The code I used on the Activate
Event of the switchboard form is below:

Private Sub Form_Activate()
On Error GoTo Err_Form_Activate

If IsLoaded("Open Sesame") Then
If DCount("*", "MessagesTable", "[Seen]=" & 1 & " And
[Destination]=" & DLookup("User", "qLoggedInUser")) > 0 Then
Mail.Visible = True
Me.TimerInterval = 500
DoCmd.OpenForm "SendMessages2", , , "[Destination]=" &
DLookup("User", "qLoggedInUser")
MsgBox "Sorry to interrupt you," & vbCrLf & _
"but you 've got a message.", vbInformation, "ECKANKAR AREA ADMIN"
Else
Mail.Visible = False
Me.TimerInterval = 0
Mail.BackColor = vbWhite
End If
End If

Exit_Form_Activate:
Exit Sub

Err_Form_Activate:
MsgBox Err.Description
Resume Exit_Form_Activate

End Sub

I have tried using the Current Event to trigger the same code but the
program hanged on an unrecognized error. The GotFocus event did not help
either as the code was not executed at all. Please help.
 
G

Glint

Thanks, Adams.
The switchboard form is always open but may be hidden once a choice is made
on the items it presents.
 
D

Dale Fye

Why are you setting the timer interval to 500, and what is the code in the
Timer event doing?

What is the Mail object you refer to?

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
G

Glint

Thanks, Dale
Mail is a textbox on the form. It has as its control source: "you have a
message." and should become visible only when a message arrives.
The Timer was to flash the Mail textbox to draw the user's attention to the
fact that there is some message for him. I thought we could go a step further
by opening the message directly, not giving him a choice.
--
Glint


Dale Fye said:
Why are you setting the timer interval to 500, and what is the code in the
Timer event doing?

What is the Mail object you refer to?

--
HTH
Dale

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.



Glint said:
Hi Guys,
I am sorry to re-post this problem I have but I have not been able to find
an explanation. It is this: I want a user to be aware that a message has
arrived for him whenever he gets to the switchboard and then take him
directly to the message by opening the appropriate form.
The problem I have is that the code appears to execute more than one time as
the msgbox in the code pops up twice or more. The code I used on the Activate
Event of the switchboard form is below:

Private Sub Form_Activate()
On Error GoTo Err_Form_Activate

If IsLoaded("Open Sesame") Then
If DCount("*", "MessagesTable", "[Seen]=" & 1 & " And
[Destination]=" & DLookup("User", "qLoggedInUser")) > 0 Then
Mail.Visible = True
Me.TimerInterval = 500
DoCmd.OpenForm "SendMessages2", , , "[Destination]=" &
DLookup("User", "qLoggedInUser")
MsgBox "Sorry to interrupt you," & vbCrLf & _
"but you 've got a message.", vbInformation, "ECKANKAR AREA ADMIN"
Else
Mail.Visible = False
Me.TimerInterval = 0
Mail.BackColor = vbWhite
End If
End If

Exit_Form_Activate:
Exit Sub

Err_Form_Activate:
MsgBox Err.Description
Resume Exit_Form_Activate

End Sub

I have tried using the Current Event to trigger the same code but the
program hanged on an unrecognized error. The GotFocus event did not help
either as the code was not executed at all. Please help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top