469,330 Members | 1,257 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,330 developers. It's quick & easy.

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

470 256MB
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.
Feb 2 '11 #1

✓ answered by NeoPa

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.
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.

9 21810
pod
298 100+
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!

Expand|Select|Wrap|Line Numbers
  1.     Do While Not rst.EOF        
  2.         Form_Main.MessageTextBox.Value = "message to display during the loop"
  3.        '-------------------------------
  4.        'the lines of code you requested
  5.         Form_Main.Refresh     ' this is the display call to be refresh
  6.         DoEvents              ' this is the request to the task manager ... I think :)
  7.        '-------------------------------
  8.         rst.MoveNext
  9.     Loop
  10.  
Feb 3 '11 #2
colintis
255 100+
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.

Expand|Select|Wrap|Line Numbers
  1. 'Open the "loading form"
  2. DoCmd.OpenForm "<name of your form>", OpenArgs:="Update"
  3.  
  4. 'This allows the code to continue while the form is opened
  5. DoEvents
  6. <Do something while the form is open>
  7.  
  8. 'Once your processes are done, close the form
  9. DoCmd.Close acForm, "<name of your form>", acSaveNo
  10.  
Feb 4 '11 #3
NeoPa
32,181 Expert Mod 16PB
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.
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.
Feb 5 '11 #4
Lysander
344 Expert 100+
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
Expand|Select|Wrap|Line Numbers
  1. Sub MESS(varText As Variant)
  2.  
  3. '   Author Mark Fisher
  4. '   Description
  5. '   ???
  6. '
  7.     On Error GoTo Err_MESS
  8. If varText = "OFF" Or Len(varText & "") = 0 Then
  9.     DoCmd.Close acForm, "fdlgMessage"
  10.     DoCmd.Hourglass False
  11. Else
  12.     DoCmd.OpenForm "fdlgMessage"
  13.     Forms!fdlgMessage!lblMessage.Caption = vbCrLf & varText
  14.     DoEvents
  15. End If
  16.  
  17. Exit_MESS:
  18.     Exit Sub
  19. Err_MESS:
  20.     MsgBox Err.Description & " in MESS"
  21.     Resume Exit_MESS
  22. End Sub
  23.  

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.

Expand|Select|Wrap|Line Numbers
  1.     setTableArray
  2.     For i = 0 To intTabCount
  3.         MESS "Setting " & arrTable(i, 0)
  4.         strSQL = "UPDATE " & arrTable(i, 0) & "  SET RecordConsistent = False;"
  5.         CurrentDb.Execute (strSQL), dbFailOnError
  6.     Next
  7.     MESS "OFF"
  8.  
  9.  
Feb 5 '11 #5
NeoPa
32,181 Expert Mod 16PB
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.
Feb 6 '11 #6
CD Tom
470 256MB
Works great, is there a way to make the message blink?
Feb 6 '11 #7
NeoPa
32,181 Expert Mod 16PB
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.
Feb 6 '11 #8
CD Tom
470 256MB
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.
Feb 7 '11 #9
NeoPa
32,181 Expert Mod 16PB
The Application.SysCmd() 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.
Feb 7 '11 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Duppypog | last post: by
5 posts views Thread by Christian Ista | last post: by
3 posts views Thread by David Allison | last post: by
2 posts views Thread by anoop | last post: by
ullevi83
9 posts views Thread by ullevi83 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.