Hi Guys,
Could use a little insight here. I have a procedure that is called in my Card Name After Update Event. The procedure attempts to check to see if the card name that I just typed in is already in the database, in other words, a duplicate card. If the procedure gets a hit then it throws up a message box telling me that a card already exists with that name and gives me the chance to delete the record and the card. I just threw something at the query that it had trouble processing probably because of punctuation in the card name. The card name is The High Priestess' Staff. My question is how to code my SQL statement to account for stuff like this. My guess is that the query is looking for the closing single quote and there isn't one, so it throws an error.
Here's the code
Any help you can provide is appreciatedCode:Private Sub CheckForDuplicates() Dim sSQL As String Dim rsCardsDuplicates As Recordset sSQL = "SELECT tblCards.[Card Name]FROM tblCards WHERE tblCards.[Card Name] = '" & txtCardName.Value & "';" If rsCards.EditMode = dbEditAdd Or rsCards.EditMode = dbEditInProgress Then Set rsCardsDuplicates = CurrentDb.OpenRecordset(sSQL, dbOpenDynaset) If rsCardsDuplicates.RecordCount > 0 Then DeleteRecord (True) End If rsCardsDuplicates.Close If Not rsCardsDuplicates Is Nothing Then Set rsCardsDuplicates = Nothing End If End If End Sub