Solved

Currency format

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 131
VBA Shell can't Find Word document 11 155
Excel Automation VBA 19 116
VBA - Excel, Hide/unhide range of rows on sheet with listbox selection 9 135
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

739 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