Solved

Currency format

Posted on 1998-12-27
5
191 Views
Last Modified: 2010-05-03
I am having problem in Currency format.  How can I avoid the user to input the decimal point(.) twice?

For example: 102.102.05

This might bugs the system when performing calculation.  I don't want to trap this by using message box but I mean to say is that not allow the user to input the second decimal point when it was press in the keyboard.  I am using MS Access97 as my database.  I use the field type, Currency in database but it doesn't seems trapping the decimal point when user input.  I also use this format:

     unitprice.Text = Format(unitprice.Text, "#,###,###.00")

But still doesn't work.  Hope to hear any comments from you.

Thank you very much.
0
Comment
Question by:tins
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:Sendoh
ID: 1452617
Hi !

try following code :

Private Sub Text4_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 110 Then
        If InStr(Text4.Text, ".") <> 0 Then
            KeyCode = 0
        End If
    End If
End Sub

Hope it'll help you !!
0
 

Author Comment

by:tins
ID: 1452618
Thanks Sendoh!  Regarding Sendoh's answer, this is working when I scan the code while running through break points. But when I left it all the way to run, it doesn't work.  I don't know why it is that way, any comment?  
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 1452619
put the same code provided by sendoh in the keypress event ,

Note: keep it in the key down event

0
 
LVL 3

Accepted Solution

by:
Sendoh earned 10 total points
ID: 1452620
Opps !
The correct way should be this :

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim str As String
   
    str = Text1.Text
    If KeyAscii = 46 Then
        If InStr(str, ".") <> 0 Then
            KeyAscii = 0
        End If
    End If
End Sub

Hope it'll suite you !!

0
 

Author Comment

by:tins
ID: 1452621
Thank you very much Sendoh!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now