Time Input Error Trap

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rebecca Smith

    #1

    Time Input Error Trap

    I'd like to trap an error if a user inputs a bogus time. The input requires
    a short time format. If the user enters someting like 20:78, Access will
    catch that but I'd like something of my own.
    Thank.
    Rebecca


  • MGFoster

    #2
    Re: Time Input Error Trap

    Rebecca Smith wrote:[color=blue]
    > I'd like to trap an error if a user inputs a bogus time. The input requires
    > a short time format. If the user enters someting like 20:78, Access will
    > catch that but I'd like something of my own.
    > Thank.
    > Rebecca
    >
    >[/color]

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Use the Form's OnError event to catch the error (2113). The following
    is a VERY basic error handler:

    Private Sub Form_Error(Data Err As Integer, Response As Integer)

    If DataErr = 2113 And Screen.ActiveCo ntrol.Name = "TimeInput" Then
    MsgBox "Invalid Time" & vbcr & _
    "The Hours must be 0 to 23 and the Minutes must be 0 to 59"
    End If

    End Sub

    --
    MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
    Oakland, CA (USA)

    -----BEGIN PGP SIGNATURE-----
    Version: PGP for Personal Privacy 5.0
    Charset: noconv

    iQA/AwUBQioNvoechKq OuFEgEQJ+yACaA+ qHh/va9Z/3hLwZAMF5BEPaGD wAn2aZ
    c7HJuNhgTNramXJ ciXTpSLgN
    =QiJN
    -----END PGP SIGNATURE-----

    Comment

    • Rebecca Smith

      #3
      Re: Time Input Error Trap

      MG,
      Using your code as written I still got the system error message after
      closing the MsgBox. So, starting with what you gave and a very wee bit of
      tweaking thanks to 'Access 97 Macro & VBA Handbook' (although my db is 2003)
      I came up with:
      *************** ****
      Private Sub Form_Error(Data Err As Integer, Response As Integer)
      Select Case DataErr
      Case 2113
      MsgBox strTimeErrorOne , , strDbTitle
      Response = acDataErrContin ue
      Case Else
      Response = acDataErrDispla y
      End Select
      End Sub
      *************** ****
      Thanks for the steer in the right direction.
      Rebecca

      PS - Haven't been to Oakland in years - I used to live over by the Rose
      Garden


      Comment

      Working...