Message appear while Access is thinking/working

T

tracktraining

Hi All,

While data are being retrieved and records are being written to forms,
Access is “frozen†(aka thinking/working), during that time … do you know if
we can have a message “Updating employee information in progress…….� After
the updating is completed, then another message appears "Employee information
updated".

Thanks,
Tracktraining
 
A

Allen Browne

You can show a message in the status bar (bottom of window), like this:
DoCmd.Echo True, "This text goes in the status bar."

Alternatively, you could put a label named (say) lblStatus on the form to
show the message, and use:
Me.lblStatus.Caption = "Please wait..."
Me.Repaint
 
D

Dale Fye

I've used both of the techniques that Allen mentioned, as well as just
turning on the hourglass, but have found that when I'm executing a series of
queries, or am looping through a recordset (I try not to do this), that
displaying a form with a status bar is very useful to the user.

I have a form (frm_message) that contains 3 controls, a label, and two
rectangles, with the label sized to about 2" wide by 1/2" high, and put the
two rectangles right below the label. Both of the labels have their
backstyle set to normal, and the box_background has the backcolor set to
grey, while box_status has it's background set to some other color (whatever
you like).

I then have three subroutines in a code module that open the form, change
the status, and close the form.

Public Sub OpenMyMessage(Message As String, _
Optional DisplayStatus As Boolean = False)

Dim frm As Form
DoCmd.OpenForm "frm_Message", , , , , , Message

Set frm = Forms("frm_Message")

frm.InsideHeight = (0.875 + (0.25 * Abs(DisplayStatus))) * 1440
frm.InsideWidth = 2.5 * 1440
frm.lbl_MyMessage.Caption = Nz(Message, "unknown")

frm.box_Background.Visible = DisplayStatus
frm.box_Status.Visible = DisplayStatus
frm.box_Status.Width = 0

frm.Repaint
DoEvents

End Sub
Public Sub MyMessageStatus(PercentComplete As Single)

Dim frm As Form
Dim sngPercent as single

sngPercent = fnMax(fnMin(PercentComplete, 100), 0)
If CurrentProject.AllForms("frm_Message").IsLoaded Then
Set frm = Forms("frm_Message")
frm.box_Status.Width = frm.box_Background.Width * sngPercent
frm.Repaint
DoEvents
End If

End Sub

Public Sub CloseMyMessage()

If CurrentProject.AllForms("frm_Message").IsLoaded Then
DoCmd.Close acForm, "frm_Message"
End If

End Sub

This code also uses two other functions from my toolbox (fnMin and fnMax),
which ensure that I don't pass a number outside of the 0 to 100 % values to
the MyMessageStatus subroutine.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dale Fye

Correction:

The line that reads:

sngPercent = fnMax(fnMin(PercentComplete, 100), 0)

should read:

sngPercent = fnMax(fnMin(PercentComplete, 1), 0)

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
D

Dale Fye

I've also used a variant on this where I added a duration to the
OpenMyMessage subroutine. This allowed me to pass the routine a message and
a duration (# of seconds), which allowed me to pop up the message and display
for a certain number of seconds, then close it again.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.
 
T

tracktraining

THANKS Allen and Dale..... the lblStatus works like a charm. I will try the
status percent complete bar.

Thank you very much!
 

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