Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

Currency Input mask

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul M - 05 Jan 2006 23:17 GMT
I am trying to create a input mask for currency, what I would like it to do
is when I type 1234567, I would like the input mask to place the "$" in front
automatically and also the decimal place so it looks like this $12,345.67,

I also would like the field to be empty until I input what ever is going
into the field, and have the number of digits be as many as I would like.  
any ideas?

Thanks,

Paul M
Wayne Morgan - 06 Jan 2006 00:30 GMT
It sounds as if you're wanting a Format instead of an Input Mask. On the
Format tab of the Properties dialog, set the format to Currency.

If you want to type in the value without typing the decimal, in the
textbox's AfterUpdate event you could divide the entered value by 100 to add
the decimal.

Example:
Me.txtMyTextbox = Me.txtMyTextbox / 100

If you wanted to check for the user typing a decimal, you could check for
the existence of the decimal in the text before the update and set a form
level flag to prevent the divide by 100 if the decimal was entered by the
user.

Example:
Option Compare Database
Option Explicit
Dim bolFlag As Boolean

Private Sub txtMyTextbox_AfterUpdate()
If Not bolFlag Then
   Me.txtMyTextbox = Me.txtMyTextbox / 100
End If
bolFlag = False
End Sub

Private Sub txtMyTextbox_BeforeUpdate(Cancel As Integer)
If InStr(Me.txtMyTextbox.Text, ".") > 0 Then
   bolFlag = True
End If
End Sub

Signature

Wayne Morgan
MS Access MVP

>I am trying to create a input mask for currency, what I would like it to do
> is when I type 1234567, I would like the input mask to place the "$" in
[quoted text clipped - 8 lines]
>
> Paul M
Paul M - 06 Jan 2006 17:17 GMT
this did not help me, I placed the code where it should have been and it did
nothing

> It sounds as if you're wanting a Format instead of an Input Mask. On the
> Format tab of the Properties dialog, set the format to Currency.
[quoted text clipped - 41 lines]
> >
> > Paul M
Wayne Morgan - 06 Jan 2006 22:04 GMT
In the textbox's Properties dialog, did you set the BeforeUpdate and
AfterUpdate events to [Event Procedure] so that it will know that there is
code to be executed?

Signature

Wayne Morgan
MS Access MVP

> this did not help me, I placed the code where it should have been and it
> did
[quoted text clipped - 50 lines]
>> >
>> > Paul M
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.