Currency Input mask

G

Guest

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
 
W

Wayne Morgan

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
 
G

Guest

this did not help me, I placed the code where it should have been and it did
nothing
 
W

Wayne Morgan

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?
 

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

Similar Threads


Top