Allow values as per the precision

Posted on 2006-04-19
Last Modified: 2010-07-27

i want to allow the user to enter the value in a field in the format
66666.45 because the corresponding column in the Oracle database can allow
number in format 5,2.
If i take the max length of the field as 7 and the user
enters the number say 6666666, the max length will pass (because the length is still 7) but while saving i get "Multiple Step Generated Errors" because the entered number does not correspond to that of the allowed max length (5,2) of the database column.
How can i validate this  and allow the user to enter the number in the
allowed format ??

Question by:acpt
    LVL 44

    Expert Comment

    Hello acpt,

    you could look at the function posted here by Rick Rothstein

    hope this helps a bit
    LVL 4

    Expert Comment

    add a test for the length of the number before the decimal point:

        Dim lngNumber As Long
        If IsNumeric(Text2.Text) Then
            lngNumber = Fix(Text2.Text)
            If Len(CStr(lngNumber)) <= 5 Then
                MsgBox "len =< 5"
                MsgBox "len > 5"
            End If
        End If
    LVL 26

    Expert Comment

    can you just check between

    99999.99 and -99999.99
    LVL 8

    Accepted Solution

    Why don't you create a mask edit box?

    with properties

    Mask = 99999.99
    Fromat = #####.##

    LVL 8

    Expert Comment

    by:Leo Eikelman
    You should be able to find the Masked Edit Control by selecting Project/Components from the IDE menu, scrolling down until you find Microsoft Masked Edit Control 6.0. If it's not there on the list, you may need to search your hard drive or installation CD for the file MSMASK32.OCX and register it with Regsvr32.


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    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…

    731 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

    16 Experts available now in Live!

    Get 1:1 Help Now