title: Sanitizing a string in Access 2003 SQL: Problem with '
body: <p>I'm writing a query that has to count the number of students enrolled in a course, and the way I'm doing it is like this:</p>
  
  <pre><code>DCount("[student/course table].[Student ID]","[student/course table]","[StartDate] = #" &amp; [Course Start Date] &amp; "# AND Location = '" &amp; tblCourseDetails.Location &amp; "' AND [Course Number] = '" &amp; [Course Number] &amp; "'")
  </code></pre>
  
  <p>The problem is that Location can contain apostrophes, which throws errors into my results. This seems to screw up a lot of things (like it asks for me to enter a parameter twice). Is there any simple way to get around apostrophes? I was thinking maybe using Replace()=Replace() which would be a pretty simple solution, but if there's any other ways around this I'd like to know.</p>
  
  <p>I'm not too worried about SQL injection. To use this query you'd have pretty much access to the database anyways.</p>
  
  <p>This isn't my whole query, if you think I should post it, tell me.</p>