Notification

  • Thread starter Thread starter David Gerstman
  • Start date Start date
D

David Gerstman

I have a userform to input some data. After the user presses the "enter"
button, the data is recorded.

I've been asked to have an indicator that flashes for a moment to indicate
that information is being saved.

I was thinking of having text in a label that would say "SAVING..." in red
letters for a second or two. How would I accomplish that?

Thank you,

David
 
What about doing it the standard way and use the Status Bar?

StatusBarStatus = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.StatusBar = "Processing... please wait"
'
' Your code goes here
'
Application.StatusBar = False
Application.DisplayStatusBar = StatusBarStatus
 
Hi,

There are many ways of doing this and here's one. Put these few lines of
code at the start of you 'Enter Button' code and you get a messagebox that
stays there for 3 seconds or until the user presses a button. Change the time
delay and message to suit your needs.


Dim Msg As String
Dim Secs As Long
Dim Wsh As Object
Title = "User Message"
Msg = "Saving data."
Secs = 3
Set Wsh = CreateObject("WScript.Shell")
RetVal = Wsh.Popup(Msg, Secs, Title, vbInformation + vbOKCancel)
Set Wsh = Nothing

Mike
 
Nice and easy

Private Sub CommandButton1_Click()
With Label1
.Caption = "Saving..."
.ForeColor = &HFF&
End With
End Sub
 
Hi

Set up you userform with a lable which in my exaple is named Label1. In the
properties for the label enter the desired message in "Caption", set
ForeColor to red and Visible =False.

Private Sub CommandButton1_Click()
Me.Label1.Visible = True
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 2' Change number to change visible time
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Me.Hide
Unload Me
End Sub

Regards,
Per
 
Jeff,

This accomplishes half of what I want.

If I want the "Saving ..." message to appear for a limited time, say a
second or two, is there some way to do that?

Thank you,

David
 
In Short? yes. The trouble is that you may be sacrificing performance for
convenience.
I suggest placing my previous post at the beginning of the Button_Click
event and return the original properties at the end. Something like this;

Sub CommandButton1_Click()
With Label1
.Caption = "Saving..."
.ForeColor = &HFF&
End With

‘Your Code here

With Label1
.Caption = "Saveâ€
.ForeColor = &H80000012
End With
End Sub
This way you’re only adding a few lines of code and not having any
unnecessary waiting
You get you’re message across for as long as it needed and that’s it.
 
Two things... First, I would use an ActiveX Label control and pre-set it up
(by sizing it, its font, its back and fore colors), then set its Visible
property to False, and then have your code make it visible before you start
your existing code and invisible once your existing code is finished.
Second, if using a Label, you will need to examine where to locate it in
case the user scrolls the worksheet (so that the Label is scrolled
off-screen). I think a construction like this can handle both of these
points...

Dim Obj As OLEObject
With Worksheets("Sheet4").OLEObjects("Label1")
.Top = Rows(ActiveWindow.ScrollRow).Top + _
ActiveWindow.Height / 2 - .Height
.Left = Columns(ActiveWindow.ScrollColumn).Left + _
ActiveWindow.Width / 2 - .Width / 2
.Visible = True
'
' << Your code goes here >>>
'
.Visible = False
End With
 
Back
Top