Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Currency format

Posted on 1998-12-27
5
Medium Priority
?
207 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
[X]
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
  • 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 30 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

719 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