Here is the situation. I have implemented a logging function into my database to create a historic record of all changes made to records in a table. The issue is that every time someone puts the comma sign " ' " into a textbox to signify the plural tense of a word, they get an error message stating syntax issues. I have determined that the cause of this issue is because my SQL statement uses the " ' " sign to seperate the different fields of the log and therefore the system is splitting my text field into multiple fields and as a result I am using too many fields in my SQL statement.
If anyone can help me modify my code so that we can use the comma sign " ' " inside the textbox again, but still be able to accomplish our goal that would be greatly appreciated.
Travis
"Why would I want to learn programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait!
Code:
Public Function WriteAudit(frm As Form, lngID As Long) As Boolean
Dim ctlC As Control
Dim fldF As Field
Dim strSQL As String
Dim bOK As Boolean
Dim strFormID As String
bOK = False
strFormID = "05"
DoCmd.SetWarnings False
Set ctlC = frm.ActiveControl
If ctlC.Value <> ctlC.OldValue Or IsNull(ctlC.OldValue) Then
If Not IsNull(ctlC.Value) Then
strSQL = "INSERT INTO tblDbLog (RecordID, UserID, DbFrmID, ActivityID, FieldChanged, FieldChangedFrom, FieldChangedTo, DateofHit) " & _
"VALUES ('" & Form_Complaints.Incident_Number & "', " & _
"'" & GetUserName_TSB() & "', " & _
"'" & "04-" & strFormID & "', " & _
"'" & "01" & "', " & _
"'" & ctlC.Name & "', " & _
"'" & ctlC.OldValue & "', " & _
"'" & ctlC.Value & "', " & _
"'" & Now() & "')"
'Debug.Print strSQL
DoCmd.RunSQL strSQL
End If
End If
WriteAudit = bOK
End Function
If anyone can help me modify my code so that we can use the comma sign " ' " inside the textbox again, but still be able to accomplish our goal that would be greatly appreciated.
Travis
"Why would I want to learn programming when Micorsoft products would be able to handle even the simplest of tasks. Oh...wait!