Results 1 to 2 of 2
  1. #1
    alex_raju is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    56

    Question if I enter except digits (a-z,!@#$%..etc) also should show cancel event function or “

    Hi sir ,
    I have a mainform and a subform , if I entry created product Id No in subform [Productid] text control other details are will appear automatically and if I enter non created any digits (product no ) msg will show as “incorrect no” and if blank [productid] text control cursor will not go to next step ( for this I amusing macro- [productid] is null- cancel event) this all working very well ,but I cannot be find correct code for if I enter except digits (a-z,!@#$%..etc) also should show cancel event function or “incorrect no” msg
    Please help me!!!!!!!!
    Private Sub ProductID_AfterUpdate()
    On Error GoTo Err_ProductID_AfterUpdate
    Dim strfilter As String
    strfilter = "productID=" & Me!ProductID
    Me!UnitPrice = DLookup("UnitPrice", "Products", strfilter)
    Me.ProductID.SetFocus
    Cancel = Not IsNumeric(ProductID)
    Exit_ProductID_Afterupdate:
    Exit Sub
    Err_ProductID_AfterUpdate:
    If Not IsNumeric(ProductID) Then
    Undo
    If Me.ProductID.Value <> DLookup("ProductId", "Products") Then
    MsgBox "incorrect no", vbCritical, "system"


    SendKeys "{home}"
    Undo
    End If


    End Sub


    Thanks
    alex

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    How bout trying the IsNumeric() function?

    If IsNumeric(txtBoxName) = False Then
    Msgbox "not numberic, try again"
    Exit Sub
    Else
    'your code here
    End If

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-19-2011, 04:28 PM
  2. Replies: 1
    Last Post: 04-06-2011, 04:33 AM
  3. Cancel form navigation event
    By tuna in forum Forms
    Replies: 3
    Last Post: 08-15-2010, 01:46 PM
  4. Cancel Selection Event for ListBox
    By is49460 in forum Forms
    Replies: 2
    Last Post: 08-04-2010, 05:53 PM
  5. Left function with various lenth of digits
    By mohsin74 in forum Queries
    Replies: 0
    Last Post: 07-10-2007, 02:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums