How to display a message on the screen while a process is going on?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CD Tom
    Contributor
    • Feb 2009
    • 495

    How to display a message on the screen while a process is going on?

    I don't know why I'm having problems with such a simple problem. I want to display a message on the screen while a process is going on then turn it off when process is complete. If it blinked while on that would be fine to.

    Thanks for your help as always.
  • pod
    Contributor
    • Sep 2007
    • 298

    #2
    this is what I do when I want to update the display while a function is running(looping )
    this message can be dynamically written too, make certain though it is inside the loop

    it is up to you to adapt this to your needs

    Bonne chance!

    Code:
        Do While Not rst.EOF        
            Form_Main.MessageTextBox.Value = "message to display during the loop"
           '-------------------------------
           'the lines of code you requested
            Form_Main.Refresh     ' this is the display call to be refresh
            DoEvents              ' this is the request to the task manager ... I think :)
           '-------------------------------
            rst.MoveNext
        Loop

    Comment

    • colintis
      Contributor
      • Mar 2010
      • 255

      #3
      Try make a form represent as the message box. When your process starts, it will open the form; Once the process is finish, the code will close the opened form.

      Code:
      'Open the "loading form"
      DoCmd.OpenForm "<name of your form>", OpenArgs:="Update"
      
      'This allows the code to continue while the form is opened
      DoEvents
      <Do something while the form is open>
      
      'Once your processes are done, close the form
      DoCmd.Close acForm, "<name of your form>", acSaveNo

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        Tom,

        I decided this was an important question that many people might benefit from knowing more about, so I wrote an article to cover it in some depth (Progress Indicator in Access). See if it helps you.
        Originally posted by CD Tom
        CD Tom:
        I don't know why I'm having problems with such a simple problem.
        As with most times people decide the problem should be simple before they understand the issues, this is not remotely a simple one. I can understand you may think it ought to be, in an ideal world possibly, but I expect you understand better now.
        Last edited by NeoPa; Feb 5 '11, 02:17 AM.

        Comment

        • Lysander
          Recognized Expert Contributor
          • Apr 2007
          • 344

          #5
          I don't know whether this helps, but I have a function "MESS" that I use in all my databases. It is very easy to use and works well for me.

          I have a small form, with all controls disabled, called fdlgMessage. It has one label on it called lblMessage. The form is set to be modal and pop-up.

          NEVER OPEN THE FORM DIRECTLY, as there is now way to close it again:)

          I then have the following routine in a global module
          Code:
          Sub MESS(varText As Variant)
          
          '   Author Mark Fisher
          '   Description
          '   ???
          '
              On Error GoTo Err_MESS
          If varText = "OFF" Or Len(varText & "") = 0 Then
              DoCmd.Close acForm, "fdlgMessage"
              DoCmd.Hourglass False
          Else
              DoCmd.OpenForm "fdlgMessage"
              Forms!fdlgMessage!lblMessage.Caption = vbCrLf & varText
              DoEvents
          End If
          
          Exit_MESS:
              Exit Sub
          Err_MESS:
              MsgBox Err.Description & " in MESS"
              Resume Exit_MESS
          End Sub

          Then anywhere in my code, if I want to display a message, whilst the code continues to run, I just type

          MESS "Please display this message"

          and then when the code has finished

          MESS "Off" (This is critical else the only way to contine is to abort access)

          For safety sake, I always have MESS "Off" in my error handler routine.

          An example of it's use in code is as follows.

          Code:
              setTableArray
              For i = 0 To intTabCount
                  MESS "Setting " & arrTable(i, 0)
                  strSQL = "UPDATE " & arrTable(i, 0) & "  SET RecordConsistent = False;"
                  CurrentDb.Execute (strSQL), dbFailOnError
              Next
              MESS "OFF"
          Last edited by Lysander; Feb 5 '11, 04:39 PM. Reason: got tags wrong, again

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32662

            #6
            Originally posted by Lysander
            Lysander:
            NEVER OPEN THE FORM DIRECTLY, as there is now way to close it again:)
            Try using Ctrl-F4. If Access Special Keys are disabled from your Startup dialog (but standard menus are still enabled) then try File \ Close. Otherwise, in such cases where everything is disabled in order to give higher control and security, put in a back-door within the form itself. Generally though, either of the first two methods should work.

            Comment

            • CD Tom
              Contributor
              • Feb 2009
              • 495

              #7
              Works great, is there a way to make the message blink?

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32662

                #8
                There is no facility within a form to specify blinking as a colour property, but if you were happy to take the performance hit, you could include code in your timer procedure to alternate the colour between two for any particular message. I doubt the performance hit would be high, to be fair, and the concept is simple enough to implement. There is already a timer routine in the example in the article, that could be changed to allow code to do this for you.

                Comment

                • CD Tom
                  Contributor
                  • Feb 2009
                  • 495

                  #9
                  I have another idea, is there a way to put a processing indicator on the bottom of this form. What I mean by a processing indicator is a bar that moves across showing the percent complete? Just a thought.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32662

                    #10
                    The Application.Sys Cmd() command was introduced in the linked article. It doesn't determine the percentage for you. You need to call the procedure each time you want it to update and specify the percentage that should be illustrated. This may be something to consider. I don't believe this shows as a control on a form though. It goes in the Status Bar. If that suits you, then you should consider it. There is more than adequate info on it if you look in the Help system for SysCmd().

                    Otherwise, designing your own control to show a percentage could easily be achieved by having a label of a certain width and filling it with the desired number of characters to illustrate the percentage desired. Any such solution would require you to determine that value for yourself though. No solution will be able to determine the progress for you automatically.

                    Comment

                    Working...