Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VALUE ENTERED ISNT VALID FOR THIS FIELD

Status
Not open for further replies.

niteraven

Technical User
Oct 26, 2006
92
US
Hi all

I have textbox on a form that is numeric data type. I am trying to have data validation instead of the ms Access error message for this field. I have tried everything, even adding a new textbox. I have deleted format "general number", default value, and for some reason cannot figure this out. I have tried code in before update, after update and on change events of the textbox, and the precanned MS Access error message shows all the time first.

Here is the code I have in the before update event of textbox:
Code:
 Dim ADL As String
    
    ADL = vbNewLine & vbNewLine
    
    If Not IsNumeric(Me.NCQty) Then
        
        msg = "QUANTITY MUST BE NUMBER VALUE!!!" & ADL & _
            "YOU MUST ENTER A NUMERIC VALUE NOT TEXT" & ADL & _
            "PLEASE REENTER A NUMERIC VALUE"
            
        Style = vbInformation + vbOKOnly
        Title = "QUANTITY MUST BE NUMBER VALUE!"
   
        MsgBox msg, Style, Title
    
        Response = acDataErrContinue
        Cancel = True
        
        Me.NCQty.Undo
        
    End If

Any help is greatly appreciated.
Raven
 
In VB I just do this:

Code:
Private Sub txtBox_KeyPress(KeyAscii As Integer)

If (KeyAscii > 47 And KeyAscii < 58) Or KeyAscii = 8 Then[green]
    'Only numbers are entered - it is OK[/green]
Else
    KeyAscii = 0
End If

End Sub

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top