IN THE SPOTLIGHT: MDE to MDB Conversion Service
(also supports: ACCDE to ACCDB, ADE to ADP, etc)
IN THE SPOTLIGHT: vbWatchdog
VBA error handling just got easier...
" vbWatchdog is off the chart. It solves a long standing problem of how to consolidate error handling into one global location and avoid repetitious code within applications. "
- Joe Anderson,
Microsoft Access MVP
Meet Shady, the vbWatchdog mascot watching over your VBA code →
(courtesy of Crystal Long, Microsoft Access MVP)
IN THE SPOTLIGHT: vbMAPI
An Outlook / MAPI code library for VBA, .NET and C# projects
Get emails out to your customers reliably, and without hassle, every single time.
Use vbMAPI alongside Microsoft Outlook to add professional emailing capabilities to your projects.
Provided by Allen Browne, May 2005. Updated May 2006.
Update: In Access 2007, if a field or control is formatted as Percent, the % is added automatically. This code is unnecessary.
When you set a field's Format property to "Percent" and enter 7, Access interprets it as 700%.
How do you get it to interpret it as 7% without having to type the percent sign for every entry?
Use the AfterUpdate event of the control to divide by 100.
But then if the user did type "7%", your code changes it to 0.07%.
We need to divide by 100 only if the user did not type the percent sign.
To do that, examine the Text property of the control.
Unlike the control's Value, the Text property is the text as you see it.
(In Access, unlike pure VB, the Text is available only for the control that has focus.)
To save the function in your database:
To apply to a text box named "Text23":
Public Function MakePercent(txt As TextBox) On Error GoTo Err_Handler 'Purpose: Divide the value by 100 if no percent sign found. 'Usage: Set the After Update property of a text box named Text23 to: ' =MakePercent([Text23]) If Not IsNull(txt) Then If InStr(txt.Text, "%") = 0 Then txt = txt / 100 End If End If Exit_Handler: Exit Function Err_Handler: If Err.Number <> 2185 Then 'No Text property unless control has focus. MsgBox "Error " & Err.Number & " - " & Err.Description End If Resume Exit_Handler End Function
|Home||Index of tips||Top|
This is a cached tutorial, reproduced with permission.
Have your say - comment on this article.
What did you think of 'Enter value as a percent'?
No comments yet.
Why not be the first to comment on this article?!
Have your say...