Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: application default messages


Message #1 by jbird@a... on Tue, 18 Mar 2003 11:36:40 -0500

Does anyone know how I can override the Access Application default messages you
get when you use an Input Mask and the user puts in the wrong format? I would
like to customize the message instead of having the user see the default
message. Any help would be greatly appreciated.



Thanks,


Joe



Message #2 by Beth Moffitt <BethMoffitt@i...> on Tue, 18 Mar 2003 11:41:42 -0600
Here's an example:

Private Sub txtBeginDate_BeforeUpdate(Cancel As Integer)
    If Err = 2279 Then
        MsgBox "Please enter valid date format.", , "Your Caption Here"
        Me.txtBeginDate = Null
        Exit Sub
    End If
End Sub


HTH,

Beth 

-----Original Message-----
From: jbird@a... [mailto:jbird@a...] 
Sent: Tuesday, March 18, 2003 10:37 AM
To: Access
Subject: [access] application default messages



Does anyone know how I can override the Access Application default messages
you
get when you use an Input Mask and the user puts in the wrong format? I
would
like to customize the message instead of having the user see the default
message. Any help would be greatly appreciated.



Thanks,


Joe




Message #3 by "Steve Klein" <Stephen@K...> on Tue, 18 Mar 2003 17:44:40 -0000
I have done the following:

1.	create a form called frmMsgbox
2.	place a close button and a label called lblmsgbox
3. 	Create a module called error_handler which has code like the following:


Function GlobalErrorHandler(DataErr As Integer, Response As Integer)



Select Case DataErr

Case 2279

    Beep
    Response = acDataErrContinue
   DoCmd.OpenForm "frmMsgbox"
  Forms![frmMsgbox]![lblMsgbox].Caption = "You must enter the date like
this: 01Jun2001" & vbCrLf _
  & vbCrLf & "CityBase will tidy up after you"
  Forms!frmMsgbox.Caption = "Sorry:- You have made a mistake with the date
format"

Case 3314
    Beep
    Response = acDataErrContinue
    MsgBox "You are trying to leave a record without entering one of the
mandatory fields" & vbCrLf _
    & "Please go back and fill the gap"
    SendKeys "{esc}"

Case 2113

    Beep
    Response = acDataErrContinue

  DoCmd.OpenForm "frmMsgbox"
  Forms![frmMsgbox]![lblMsgbox].Caption = "You have entered an impossible
date " & vbCrLf _
  & vbCrLf & "Check your spelling and the number of days in the month and
try again."
  Forms!frmMsgbox.Caption = "Sorry:- You have made a mistake with the date"

Case 2001
    Beep
    Response = acDataErrContinue

    MsgBox "I think you are trying to delete a new record." & vbCrLf _
    & "The computer does not think this record exists yet" & vbCrLf _
    & "        Please try again"



 Case 94
    Beep
    Response = acDataErrContinue

   DoCmd.OpenForm "frmMsgbox"
  Forms![frmMsgbox]![lblMsgbox].Caption = "You are trying to work on a
record that doesn't exist." & vbCrLf _
  & vbCrLf & "That's too zen for me.  Please try again" & vbCrLf _
  & Forms![frmMsgbox].Caption = "Sorry: I'm confused"


 Case 2237

    Beep
    Response = acDataErrContinue

    DoCmd.OpenForm "frmMsgbox"
    Forms![frmMsgbox]![lblMsgbox].Caption = "You are trying to enter
something that is not on the list" & vbCrLf _
    & vbCrLf & "If you can't find what you need ring IT support and they can
add it"
    Forms![frmMsgbox].Caption = "That item is not allowed"


Case Else

GlobalErrorHandler = acDataErrDisplay


End Select
End Function



4. add the follwing to every form

Private Sub Form_Error(DataErr As Integer, Response As Integer)
    Response = GlobalErrorHandler(DataErr, Response)
End Sub


You can add errors to the list as you find them


Steve K


-----Original Message-----
From: jbird@a... [mailto:jbird@a...]
Sent: 18 March 2003 16:37
To: Access
Subject: [access] application default messages




Does anyone know how I can override the Access Application default messages
you
get when you use an Input Mask and the user puts in the wrong format? I
would
like to customize the message instead of having the user see the default
message. Any help would be greatly appreciated.



Thanks,


Joe





Message #4 by jbird@a... on Tue, 18 Mar 2003 13:30:39 -0500

That was very helpful. Thanks!!

-Joe



Message #5 by jbird@a... on Tue, 18 Mar 2003 13:31:09 -0500

Thanks, Beth. I appreciate it.




  Return to Index