[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Clear alert on a timer

Posted on 2011-10-18
12
Medium Priority
?
254 Views
Last Modified: 2012-05-12
When an user is entering data in a form there are some logical errors that may occur.  These are not serious until the ‘Save’ button is clicked.  I would like to advise the user by the way of a gentle alert that there is a problem.

For example if the cost is 10 and the charge is 9 then there is a problem that needs addressing.

So I have created a label that is normally not visible.  The caption on the label is then set to explain the problem i.e.

Me.lblAlert.Caption = “Cost is higher than charge”
Me.lblAlert.Visible = True
DoCmd.Beep

… but I would like to clear the alert after a few seconds with:

Me.lblAlert.Visible = False

I am not sure how long to leave the alert visible but I can experiment.

Does anyone have some timer code that would achieve this please?
0
Comment
Question by:MikeDTE
  • 5
  • 5
  • 2
12 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36985355
Place a value of 10000  in your Timer Interval property (this is measured in milliseconds, so that is 10 seconds).

Then in the Timer Event, add the following:

Me.lblAlert.Visible = False
Me.TimerInterval = 0   '<--- turns off the timer


You will also need code added to whatever event displays the label to set the timer:

Me.lblAlert.Caption = “Cost is higher than charge”
Me.lblAlert.Visible = True
DoCmd.Beep
Me.TimerInterval = 10000
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36985369
Actually - skip the part about adding the 10000 to the property sheet.   You don't want this to happen automatically when the form opens; you just want it to happen when your code triggers it.
0
 

Author Comment

by:MikeDTE
ID: 36985466
Hi mbizup

Good to hear from you again

I do not have any specific code to set the label as not visible - I just set the property in the designer to 'Visible=No'.

So would I add

Me.lblAlert.Visible = False
Me.TimerInterval = 0   '<--- turns off the timer

in Form_Load

and then

Me.lblAlert.Caption = “Cost is higher than charge”
Me.lblAlert.Visible = True
DoCmd.Beep
Me.TimerInterval = 10000

in the _AfterUpdate  

Just checking to see if I got it right!

0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 

Author Comment

by:MikeDTE
ID: 36985508
Hi mbizup

Just tried out the code as I had assumed it would be inserted ... but it doesn't work

The line 'Me.TimerInterval = 10000' has no affect at all!

Is there not a timer function to add somewhere?

Also the DoCmd.Beep is conspicuous by it's silence

Regards
Mike
0
 
LVL 61

Accepted Solution

by:
mbizup earned 1000 total points
ID: 36985525
Hi Mike,

Not quite...

This goes in the form Timer event (not the load event).  The timer event gets fiered at whatever interval is specified either in the property sheet or through code.

Private Sub Form_Timer()
    Me.lblAlert.Visible = False
    Me.TimerInterval = 0   '<--- turns off the timer
End Sub

Open in new window


And this goes wherever you need to make this label visible - you want to start the timer as soon as the label is made visible, so that the label gets 'turned off' after 10 seconds:

Me.lblAlert.Caption = “Cost is higher than charge”
Me.lblAlert.Visible = True
DoCmd.Beep
Me.TimerInterval = 10000

Open in new window


0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 36985526
Mike,

Yes, you need to add same code you have in the form_load event to the Timer event:

Private sub Form_Timer

    Me.lblAlert.Visible = False
    Me.TimerInterval = 0   '<--- turns off the timer

End Sub
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36985552
<< Also the DoCmd.Beep is conspicuous by it's silence >>

Really?  I'm not sure why you don't hear a sound - it makes a short, low 'beep' here...
0
 

Author Comment

by:MikeDTE
ID: 36985569
Thanks mbizup

Original problem resolved - timer working faultlessly - the points are yours.

Beep still missing at this end - I'll do some browsing and see if anybody else has a silent (and deadly) beep!

Regards
Mike

0
 

Author Closing Comment

by:MikeDTE
ID: 36985574
Excellent answer - thanks
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36985592
Glad that worked out!

Not sure about your beep() issue...

Both of these are alternatives for making sounds:

msgbox "Beep",vbexclamation
msgbox "Beep",vbCritical

But they might not fit in well with what you are doing.

0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 36985596
The problem with the Beep is that you cannot control the volume, so if your volume is turned way down, and there are noises around you, or you are playing your Internet radio, you could very well not hear the beep.

I generally prefer to pop-up a  message box, which displays a specific message and the places the cursor back in the appropriate control.  The msgbox will not go away until manually cleared, and forcing the focus back to an offending value just makes sense.  Otherwise, they have to read your message, understand it, and move the focus back to the offending control on their own.
0
 

Author Comment

by:MikeDTE
ID: 36985624
Hi fyed

Thanks for your observations.  The msgbox method was considered, tried and rejected as too clumsy.  The subtle prompt achieved by the appearance of a label and it's timed clearance is much more appropriate in this case.

The beep - the volume was the problem.  Interestingly I can't get to the volume properties but all my multimedia sounds work - music CD's, DVD soundtracks, internet radio etc. all work.  System sounds (the Windows Default sound scheme is enabled) do not work.  This is a problem with my PC but that will not be the case on the client's systems.  So hey! I can live without the beeps.

Regards
Mike
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question