INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Functions

What's an easy way to get feedback and/or error messages to tables for future reference? by AlanJordan
Posted: 6 Dec 05 (Edited 8 Dec 05)

I adapt this code to several different routines including:
LogAMessage, LogAuditInfo, LogProcessInfo and LogAMessage.  Perhaps it will also be helpful to you.

CODE

Function LogUserComment(Optional strMsg As String, Optional strKKLogin As String, Optional strPgmrsComments As String, Optional strUrgencyLevel As String, _
    Optional dblProcessingTime As Double, Optional dblOtherStat As Double) As Boolean
        
On Error GoTo errLAM
Dim strSQL As String
        Dim db As Database
        If IsMissing(strMsg) Then strMsg = """"
        If IsMissing(strKKLogin) Then strKKLogin = """"
        If IsMissing(strPgmrsComments) Then strPgmrsComments = """" Else strPgmrsComments = Chr(34) & strPgmrsComments & Chr(34)
        If IsMissing(strUrgencyLevel) Then strUrgencyLevel = """" Else strUrgencyLevel = Chr(34) & strUrgencyLevel & Chr(34)
        Set db = CurrentDb
        strSQL = "INSERT INTO UserComments (Message, KKLoginOrName, ProgrammerComments, UrgencyLevel,ProcessingTime, OtherStat) Values ( """ & strMsg & """,'" & strKKLogin & "'," & _
         strPgmrsComments & "," & strUrgencyLevel & "," & dblProcessingTime & "," & dblOtherStat & ")"
        'debug.print strSQL
        DoCmd.SetWarnings False
        CurrentDb.Execute (strSQL)

        DoCmd.SetWarnings True
        Set db = Nothing
        LogUserComment = True
Exit Function
errLAM:
    LogUserComment = False
    Select Case Err.Number
        Case 3075
            MsgBox "Please reenter your message.  Do not use quote marks. Thank you.", vbInformation
            
            Exit Function
        Case Else
            
            ErrBox ("The problem originated in the function LogUserComment in modUtilities.")
    End Select
End Function

Here's the ErrBox Function

CODE

Public Sub ErrBox(Optional varProblemType As Variant, Optional strUrgencyLevel As String, Optional dblNumRef1 As Double, Optional dblNumRef2 As Double)
'Note:  The case functionality has been anticipated, but no differentiation is made yet.
'FU
Dim strMsg As String

    If IsNull(varProblemType) Then 'there is a type of problem indicated
            strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            MsgBox strMsg
    Else
            Select Case varProblemType
            Case "FL"
               strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "." _
               & vbCrLf & vbCrLf & "Note:  Tell a programmer that the problem originated while loading the form."
            Case 1
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            Case 2
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & "."
            Case Else
                strMsg = "There is a problem.  It is " & Err.Number & " - " & Err.Description & " -  Source: " & Err.Source & "."
            End Select
            MsgBox strMsg
            Call LogAMessage(strMsg, , CStr(varProblemType), "", dblNumRef1, dblNumRef2)
    End If
End Sub

Back to Microsoft: Access Modules (VBA Coding) FAQ Index
Back to Microsoft: Access Modules (VBA Coding) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close