PC Review


Reply
Thread Tools Rate Thread

Cancel timer event if criteria not met

 
 
Kurt
Guest
Posts: n/a
 
      13th Feb 2011
I have a popup form with Modal = No.

I use the Timer event to close it: TimerInterval = 200 plus this code:

Private Sub Form_Timer()
' error triggers when user clicks outside of form
On Error GoTo NotForm:

If Me.Name = Screen.ActiveForm.Name Then Exit Sub

NotForm:
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

If the user clicks outside the form, but the form record fails some
criteria (e.g., fldABC is Null), I'd like Access to cancel/prevent
whatever the user just tried to do (like opening another form), keep
the form open, and prompt him that he needs to address the missing
criteria or Cancel the record.

The use of the timer has made this all sorts of challenging, but I'd
like to keep the timer feature if possible.

I've tried all sorts of ways and can't get it working. One way is
below. It led to a disaster in which I was able to open another popup
form, which was then set Modal = True, and I had to CTL+ALT+DEL my way
out of it. But I may be going about it all wrong.

###

Private Sub Form_Timer()
On Error GoTo NotForm:
If Me.Name = Screen.ActiveForm.Name Then Exit Sub
NotForm: ' user clicked outside of form
If IsNull(Me.fldABC) Then
' Prevent user from leaving the form for executing other
events
Me.Modal = True
' Turn off timer (so msgbox doesn't keep firing)
Me.TimerInterval = 0
MsgBox "Fix date"
Else
Me.Modal = False
Me.TimerInterval = 200 ' set timer back
DoCmd.Close acForm, Me.Name, acSaveNo
End If
End If
End Sub

###

I tried also relying the BeforeUpdate event to prompt the user, but
that occurs after the TimerEvent triggers, so the form closed before
the user got the prompt to fix the issue.
 
Reply With Quote
 
 
 
 
Douglas J Steele
Guest
Posts: n/a
 
      13th Feb 2011
Put logic into the form's Unload event. If there's a condition that needs
correcting, simply set Cancel = True.


"Kurt" wrote in message
news:9ac9d302-0751-47cf-9845-(E-Mail Removed)...

I have a popup form with Modal = No.

I use the Timer event to close it: TimerInterval = 200 plus this code:

Private Sub Form_Timer()
' error triggers when user clicks outside of form
On Error GoTo NotForm:

If Me.Name = Screen.ActiveForm.Name Then Exit Sub

NotForm:
DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

If the user clicks outside the form, but the form record fails some
criteria (e.g., fldABC is Null), I'd like Access to cancel/prevent
whatever the user just tried to do (like opening another form), keep
the form open, and prompt him that he needs to address the missing
criteria or Cancel the record.

The use of the timer has made this all sorts of challenging, but I'd
like to keep the timer feature if possible.

I've tried all sorts of ways and can't get it working. One way is
below. It led to a disaster in which I was able to open another popup
form, which was then set Modal = True, and I had to CTL+ALT+DEL my way
out of it. But I may be going about it all wrong.

###

Private Sub Form_Timer()
On Error GoTo NotForm:
If Me.Name = Screen.ActiveForm.Name Then Exit Sub
NotForm: ' user clicked outside of form
If IsNull(Me.fldABC) Then
' Prevent user from leaving the form for executing other
events
Me.Modal = True
' Turn off timer (so msgbox doesn't keep firing)
Me.TimerInterval = 0
MsgBox "Fix date"
Else
Me.Modal = False
Me.TimerInterval = 200 ' set timer back
DoCmd.Close acForm, Me.Name, acSaveNo
End If
End If
End Sub

###

I tried also relying the BeforeUpdate event to prompt the user, but
that occurs after the TimerEvent triggers, so the form closed before
the user got the prompt to fix the issue.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Cancel a Cancel Button event Eric T. Microsoft Dot NET Framework Forms 3 5th Feb 2009 11:36 PM
CancelEventArgs.Cancel - How Event Raising Code Know if Client Set .Cancel=true Smithers Microsoft C# .NET 3 24th Sep 2007 02:30 AM
Close Access, or Timer/Timer Event Help =?Utf-8?B?V2VuZHk=?= Microsoft Access VBA Modules 2 16th Apr 2007 03:54 AM
Cancel Cllick Event Won't Cancel Mike Boozer Microsoft Access Form Coding 4 28th Apr 2004 02:36 AM
Can the count down timer to cancel disk check be changed? -me- Windows XP Customization 4 17th Nov 2003 03:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:46 AM.