UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Prevent Form From Popping Up If User Is Typing..., Access 2010    
 
   
AdamL
post Jun 19 2017, 12:41 PM
Post#1



Posts: 143
Joined: 12-March 00
From: New York, NY


I have a reminder form that is called to pop up every 30 minutes. Before I open the form, I want to determine if the user is entering any information, vs. just viewing a screen/Report/Query. If the user is entering information, (typing in a text box,) I want to skip the calling of the reminder form pop up. I thought about using the Form.Dirty Property but I'm unable to determine which form or report or query the user will be on when the Timer Interval is reached and the On Timer is Event is triggered. Any suggestions would be greatly appreciated.
Go to the top of the page
 
theDBguy
post Jun 19 2017, 12:44 PM
Post#2


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Hi,

Have you tried using Screen.ActiveForm to determine on which form the user is currently working?

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
BruceM
post Jun 19 2017, 01:07 PM
Post#3


UtterAccess VIP
Posts: 6,832
Joined: 24-May 10
From: Downeast Maine


QUOTE
Any suggestions would be greatly appreciated.

Don't use a popup reminder?

I'm being somewhat serious, as I am somebody who despises IM and just about anything that imposes itself upon the screeen while I am doing something. But perhaps I am unusually touchy in that regard.

That said, you could write the current time of day to a TempVar when some appropriate form is opened. In the Current event, compare that time to the current time to determine whether 30 minutes has elapsed. If so, do the reminder then, and reset the TempVar to the current time. You can use the Current event to set the initial value, then verify it later. In this way the message occurs only when moving to another record.
CODE
Private Sub Form_Current()

  Dim dat30 As Date
  Dim int30 As Integer

  dat30 = CDate(Nz(TempVars!CurrTime,Now()))
  int30 = DateDiff("n",dat30,Now())

  If int30 >= 30 Then
      MsgBox "Hey there!"
      TempVars!CurrTime = Now()
  End If

End Sub
Go to the top of the page
 
doctor9
post Jun 19 2017, 01:19 PM
Post#4


UtterAccess Editor
Posts: 17,609
Joined: 29-March 05
From: Wisconsin


AdamL,

For the record, I'm with Bruce. Maybe consider a different way of handling the reminder. If data entry is enough to cancel the reminder, how important is the reminder? Perhaps have a textbox in the data entry form's header that displays messages, rather than a separate form.

Hope this helps,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
AdamL
post Jun 19 2017, 01:28 PM
Post#5



Posts: 143
Joined: 12-March 00
From: New York, NY


BruceM & doctor9,

I appreciate your input but this is a rabbit hole I have to travel down. :-)

theDBguy,

Thanks that helps. Using Screen.ActiveForm if one of the forms was a tabbed form would it be considered Dirty if any textbox on any tab in that form was Dirty?

AdamL
Go to the top of the page
 
theDBguy
post Jun 19 2017, 01:38 PM
Post#6


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Hi Adam,

If you're referring to a subform, then the answer would be a No, because the subform would be Dirty and not the main form. If so, you might want to use something like this:

Screen.ActiveControl.Parent.Dirty

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
BruceM
post Jun 19 2017, 01:49 PM
Post#7


UtterAccess VIP
Posts: 6,832
Joined: 24-May 10
From: Downeast Maine


DBGuy, will the parent form ever be dirty if the user is on the subform? Moving to the subform saves the parent record, AFAIK.
QUOTE
Using Screen.ActiveForm if one of the forms was a tabbed form would it be considered Dirty if any textbox on any tab in that form was Dirty?

All controls on a tab control are part of the form on which the tab control resides, and therefore can be evaluated together. However, if one of the tab pages includes a subform control, that subform is not part of the main form. The subform control is a "box" on the main form that contains the subform. The subform control is on the main form, but the actual subform is not.
Go to the top of the page
 
theDBguy
post Jun 19 2017, 01:59 PM
Post#8


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Re: "DBGuy, will the parent form ever be dirty if the user is on the subform? Moving to the subform saves the parent record, AFAIK."

Correct, and it is why I said the answer is a No if the OP tries to use Screen.ActiveForm.Dirty because the active form will always be the main form even if the user is currently editing the subform.

Just my 2 cents...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
AdamL
post Jun 19 2017, 02:07 PM
Post#9



Posts: 143
Joined: 12-March 00
From: New York, NY


This worked perfectly.

If Screen.ActiveControl.Parent.Dirty = False Then
{Open Form}
End If

Thank you for your help.

AdamL
Go to the top of the page
 
BruceM
post Jun 19 2017, 02:57 PM
Post#10


UtterAccess VIP
Posts: 6,832
Joined: 24-May 10
From: Downeast Maine


Oh, is that how ActiveForm works? Well, I just learned something new. Cool!
Go to the top of the page
 
theDBguy
post Jun 19 2017, 03:03 PM
Post#11


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Hi Adam,

You're welcome. Glad to hear you got it to work. We're all happy to assist. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
AdamL
post Jun 19 2017, 04:33 PM
Post#12



Posts: 143
Joined: 12-March 00
From: New York, NY


I ran into a problem. If a Report or Query is the "ActiveForm" Access returns Run-time error 2475, "You entered an expression that requires a form to be the active window." Is there a way to test if a Report or Query is the "ActiveForm?"

AdamL
Go to the top of the page
 
theDBguy
post Jun 19 2017, 05:08 PM
Post#13


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Hi,

ActiveForm refers to Forms. For Reports, you could use ActiveReport. For Queries, you could try ActiveDatasheet.

Hope it helps...

PS. Are you allowing users to "enter" data on reports too?

This post has been edited by theDBguy: Jun 19 2017, 05:09 PM

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
AdamL
post Jun 19 2017, 05:50 PM
Post#14



Posts: 143
Joined: 12-March 00
From: New York, NY


theDBguy,

No, the only data entry would be in a form but since I don't know what will be active, is there a way to test for all three (ActiveForm, ActiveReport or ActiveDatasheet) without getting an error? I'd only have to test for Dirty if the user is viewing a form. If they are viewing a Report or Query, I would open the reminder form as planned.

Here is a review what I'd like to have happen:

After 30 minutes, the Timer Event fires.
I don't know what the user is looking at but there are only three possibilities: A form, a report or the results of a query.
If it is a form that is not being edited (Me.Dirty = False) or a report or the results of a query, the reminder form should be opened.
If it is a form that is being edited (Me.Dirty = True) the reminder form should not be opened.

I hope this makes things clearer.

AdamL
Go to the top of the page
 
AdamL
post Jun 19 2017, 06:16 PM
Post#15



Posts: 143
Joined: 12-March 00
From: New York, NY


I found the solution:

CODE
If Application.CurrentObjectType = acForm Then
  If Screen.ActiveControl.Parent.Dirty = True Then
        Exit Sub
  End If
End If
  
{Open Form}


Thank you for your help!
Go to the top of the page
 
ADezii
post Jun 19 2017, 06:53 PM
Post#16



Posts: 1,782
Joined: 4-February 07
From: USA, Florida, Delray Beach


  1. I was thinking along a different line.
  2. Set the TimerInterval Property to an appropriate Value (in milliseconds).
  3. Place Code in the Form's Timer() Event that will:
    1. Determine the Current Object Type and Name.
    2. Check the Current Object to see if it is Dirty.
    3. If it is NOT Dirty, then Open the Reminder Form.
  4. Code currently works for Forms and Reports right now.
  5. The Form associated with this Timer Event Code must be Open (can be minimized).
  6. This Code is mostly Theory at this point and hasn't been extensively tested.
    CODE
    Private Sub Form_Timer()
    Dim intObjType As Integer
    Dim strObjName As String
    Dim intObjState As Integer

    intObjType = Application.CurrentObjectType
    strObjName = Application.CurrentObjectName

    Select Case intObjType
      Case acForm
        If Not Forms(strObjName).Dirty Then
          'Current Object is a Form that is not Dirty, open Reminder Form
        End If
      Case acReport
        If Not Reports(strObjName).Dirty Then
          'Current Object is a Report that is not Dirty, open Reminder Form
        End If
    End Select
    End Sub
Go to the top of the page
 
theDBguy
post Jun 19 2017, 07:46 PM
Post#17


Access Wiki and Forums Moderator
Posts: 70,667
Joined: 19-June 07
From: SunnySandyEggo


Hi Adam,

Glad to hear you found a solution. Good luck with your project.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
AdamL
post Jun 20 2017, 03:10 AM
Post#18



Posts: 143
Joined: 12-March 00
From: New York, NY


ADezii,

Thanks for your suggestion.

AdamL
Go to the top of the page
 
ADezii
post Jun 20 2017, 05:38 AM
Post#19



Posts: 1,782
Joined: 4-February 07
From: USA, Florida, Delray Beach


yw.gif
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd September 2017 - 10:49 PM