Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Currency format

Posted on 1998-12-27
5
195 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

809 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