This one has me stumped so I would really appreciate some help.
So, I created some error logging capacity inside my application (MS Access 2013 Split DB 32-Bit) . In doing so, I created generic Error Handler procedures to track the errors with the help of MZ Tools.
The error logging works absolutely fine UNTIL, the error involves the application not being able to locate a referenced control in a form.
For example: 'Error: 2450 (System cannot find the referenced form 'frm_entity'.) in procedure xyz...'
When this occurs, the string that is built in the Error Handler for my "Log Description" field contains single quotation characters that Access just does not seem to like.
Following is an outline of everything in code to the actual error and simple mitigation.
My table design:
Sample of code used inside my generic Error Handlers which is the same approach across the entire database.
On Error GoTo populate_entity_wizard_Err_HandlerErr_Handler_Exit: Exit Functionpopulate_entity_wizard_Err_Handler: If Err.Number = 0 Then Resume Err_Handler_Exit Else Call addDBLog(6, "Error: " & Err.Number & " (" & Err.Description & ") in procedure populate_entity_wizard of Module bas_entity") MsgBox "An unexpected application error has been detected." & vbCrLf & "" & vbCrLf & _ "Error: " & Err.Number & " (" & Err.Description & ") in procedure populate_entity_wizard of Module bas_entity." & vbCrLf & "" & vbCrLf & _ "Please note the above details before raising a support ticket.", vbOKOnly, "Support" Resume Err_Handler_Exit End If
The following SQL is a debug of the above procedure which has been slightly modified to retain privacy. This is an example of the string that causes the error:
INSERT INTO tbl_logs (LogUserID, LogUserName, LogCode, LogDescription, LogDate, LogDateTimeStamp) SELECT 1 as LogUserID, 'Test User' AS LogUserName, 6 AS LogCode, 'Error: 2450 (System cannot find the referenced form 'frm_entity'.) in procedure populate_entity_wizard of Module bas_entity' AS LogDescription, '25/06/2015 1:03:31 PM' AS LogDate, '25/06/2015 1:03:31 PM' AS LogDateTimeStamp
Below is the same debug as above but with the quotations taken out (i.e. 'frm_entity' becomes frm_entity) and it works fine:
INSERT INTO tbl_logs ( LogUserID, LogUserName, LogCode, LogDescription, LogDate, LogDateTimeStamp )SELECT 1 AS LogUserID, 'Test User' AS LogUserName, 6 AS LogCode, 'Error: 2450 (System cannot find the referenced form frm_entity.) in procedure populate_entity_wizard of Module bas_entity' AS LogDescription, '25/06/2015 1:03:31 PM' AS LogDate, '25/06/2015 1:03:31 PM' AS LogDateTimeStamp
In case you have missed, it might also be worth noting that I only ever parse two variables when calling the log procedure. These are:
LogCode
LogDescription
Everything else is collected from TempVars or assigned on the fly.
Has anyone got any ideas on how I can get this type of log description written to a table without the errors occurring or taking another approach without changing to much of my code?
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.