opening a form from a value

Amy35

Registered User.
Local time
Today, 22:56
Joined
Mar 12, 2002
Messages
53
I have the below code on the double-click event. It works sometimes. The times it doesn't is when the ProblemDescription field (which is being used to match the record) has a quote in it. As an example, the problem description might read: I can't logon to the LAN. The ' in can't causes a problem Or if someone puts "" in their problem description. Here's the error message: Syntax error (missing operator) in query expression '[ProblemDescription]='I can't logon to the LAN".
Anyone know how to fix this? Thanks in advance.

Amy

Private Sub ProblemDescription_DblClick(Cancel As Integer)
On Error GoTo Err_cmdFullView_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOpenTickets"

stLinkCriteria = "[ProblemDescription]=" & "'" & Me![ProblemDescription] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdFullView_Click:
Exit Sub

Err_cmdFullView_Click:
MsgBox Err.Description
Resume Exit_cmdFullView_Click

End Sub
 
Amy,

Is there no way you can use the ID of the record to filter the form rather than the text description? I'm assuming that each problem is recorded in a table and therefore is likely to have an unique ID. Failing that, another option is to strip all punctuation from the text description with a custom function before storing it in the table but this will make it confusing to read on a form / report.

HTH
 

Users who are viewing this thread

Back
Top Bottom