Solved

Communication Error

Posted on 1998-06-03
1
212 Views
Last Modified: 2010-05-03
I am trying to log all my communication Error messages to the log file.
 ERMsg$ = "Break Received"
            lLogType = vbLogEventTypeError
            sPrintMsg = ERMsg$ & vbCrLf & _
            " Error: [" & Err.Number & "]: " & _
            Err.Description & " Error in: " & Err.Sorce
           
            App.LogPath = "C:\HLRS4.1\Error.log"
            App.StartLogging App.LogPath, vbLogAuto
            App.LogEvent sPrintMsg, lLogType
I created an empty log file on my c drive. But I am getting  error : Can't assign to the read-only property
 App.LogPath = "C:\HLRS4.1\Error.log"
Returns the path and filename of the file used to capture output from the LogEvent method. Not available at design-time; read-only at run time.

From the Help menu:

Syntax

object.LogPath = path

Part      Description
object      An object expression that evaluates to an object                  in the Applies To list.
path      String. The path and filename of a log file.

what changes should i make to my code ? Thank you...


Private Static Sub MSComm1_OnComm()
    Dim EVMsg$
    Dim ERMsg$
    Dim sPrintMsg As String
    Dim lLogType As Long
    ' Branch according to the CommEvent property.
    Select Case MSComm1.CommEvent
        ' Event messages.
        Case comEvReceive
            Dim Buffer As Variant
            Buffer = MSComm1.Input
            Debug.Print "Receive - " & StrConv(Buffer, vbUnicode)
            ShowData txtTerm, (StrConv(Buffer, vbUnicode))
        Case comEvSend
        Case comEvCTS
            EVMsg$ = "Change in CTS Detected"
        Case comEvDSR
            EVMsg$ = "Change in DSR Detected"
        Case comEvCD
            EVMsg$ = "Change in CD Detected"
        Case comEvRing
            EVMsg$ = "The Phone is Ringing"
        Case comEvEOF
            EVMsg$ = "End of File Detected"

        ' Error messages.
        Case comBreak
            ERMsg$ = "Break Received"
            lLogType = vbLogEventTypeError
            sPrintMsg = ERMsg$ & vbCrLf & _
            " Error: [" & Err.Number & "]: " & _
            Err.Description & " Error in: " & Err.Sorce
           
            App.LogPath = "C:\HLRS4.1\Error.log"
            App.StartLogging App.LogPath, vbLogAuto
            App.LogEvent sPrintMsg, lLogType
0
Comment
Question by:gima
1 Comment
 
LVL 1

Accepted Solution

by:
JayMerritt earned 20 total points
Comment Utility
Try :

'REM App.LogPath = "C:\HLRS4.1\Error.log"
App.StartLogging "C:\HLRS4.1\Error.log", vbLogAuto
App.LogEvent sPrintMsg, lLogType


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now