G
Greg Snidow
Greetings all. I am using Access 2000 and SQL Server 2000. I have a form
with subform for comments. I was receiving errors that said "the data will
be saved but can not be displayed...", and found a KB article saying it was
an issue with ADP 2000. So, my solution was to change the way people enter
notes. I put an unbound text box, txtAddNote, and a command button,
cmdAddNote, then run some SQL to insert the note, and then requery the
subform. The problem is that I did not think about what would happen if
someone entered in single quotes, such as "Joe's from VA". I can not expect
all users to enter it like Joe''s, nor can I expect them to remember to never
use single quotes. So, my question is, how can I write it so that the users
can type whatever they want? The below is what I have currently working.
*******************************
On Error GoTo Err_cmdAddNote_gotfocus
Dim strSQL As String
strSQL = "INSERT INTO tblcmc_comments
(ewo,entered_dt,entered_by,comments) " & _
"SELECT '" & Me.txtEWO & "',GETDATE(),SYSTEM_USER,'" &
Me.[txtAddNote] & "'"
DoCmd.RunSQL strSQL
Me.frmSearchEWO_CommentsSub.Form.Requery
Me.txtAddNote = ""
Exit_cmdAddNote_gotfocus:
*********************************************
The last field in the INSERT statement, comments, is the field in question.
Thank you.
with subform for comments. I was receiving errors that said "the data will
be saved but can not be displayed...", and found a KB article saying it was
an issue with ADP 2000. So, my solution was to change the way people enter
notes. I put an unbound text box, txtAddNote, and a command button,
cmdAddNote, then run some SQL to insert the note, and then requery the
subform. The problem is that I did not think about what would happen if
someone entered in single quotes, such as "Joe's from VA". I can not expect
all users to enter it like Joe''s, nor can I expect them to remember to never
use single quotes. So, my question is, how can I write it so that the users
can type whatever they want? The below is what I have currently working.
*******************************
On Error GoTo Err_cmdAddNote_gotfocus
Dim strSQL As String
strSQL = "INSERT INTO tblcmc_comments
(ewo,entered_dt,entered_by,comments) " & _
"SELECT '" & Me.txtEWO & "',GETDATE(),SYSTEM_USER,'" &
Me.[txtAddNote] & "'"
DoCmd.RunSQL strSQL
Me.frmSearchEWO_CommentsSub.Form.Requery
Me.txtAddNote = ""
Exit_cmdAddNote_gotfocus:
*********************************************
The last field in the INSERT statement, comments, is the field in question.
Thank you.