Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem logging error descriptions 1

Status
Not open for further replies.

BaudKarma

Programmer
Feb 11, 2005
194
0
0
US
I'm trying to set up a simple error logging routine for my project. I call an error logging function, passing along the relevant variables, and the error logging function uses a DOCMD.RUNSQL INSERT INTO command to shove the data into the appropriate table.

The problem I'm running into occurs when the error description has single quotes in it. For example, a misspelled field gives the message:

Access can't find the field 'Initt" referred to in your expression.

Problem is, when I try to put single quotes around the whole message for the runsql command, it hits the single quotes around the field name and breaks. Is there a way around this?



I try not to let my ignorance prevent me from offering a strong opinion.
 
With the runsql method of the docmd object, you can doublequote - something like this:

[tt]"insert into blah (num, msg) values (" & lngnum & ",""" & strMsg & """)"[/tt]

Roy-Vidar
 
Replace(Err.Description, [tt]"'", "''"[/tt])

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Replace does the trick. Thanks!

I try not to let my ignorance prevent me from offering a strong opinion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top