JithuAccess
Member
- Local time
- Today, 04:43
- Joined
- Mar 3, 2020
- Messages
- 325
Hello Guys,
I was trying to add the Values in a Combo Box on the fly. I have put the following code:
Private Sub Combo41_NotInList(NewData As String, Response As Integer)
Dim StrSQL As String
Dim i As Integer
Dim Msg As String
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Add New?")
If i = vbYes Then
StrSQL = "Insert Into [My Table] ([My Field]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute StrSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
It was working fine. But if I add a Text like "Children's Hospital" I am getting an error like below:
The problem is with the Apostrophe in the Word Childrens'. Could you kindly let me know how to resolve this. Or do I have to avoid the Apostrophe ?
Thanks a lot
I was trying to add the Values in a Combo Box on the fly. I have put the following code:
Private Sub Combo41_NotInList(NewData As String, Response As Integer)
Dim StrSQL As String
Dim i As Integer
Dim Msg As String
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Add New?")
If i = vbYes Then
StrSQL = "Insert Into [My Table] ([My Field]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute StrSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
It was working fine. But if I add a Text like "Children's Hospital" I am getting an error like below:
The problem is with the Apostrophe in the Word Childrens'. Could you kindly let me know how to resolve this. Or do I have to avoid the Apostrophe ?
Thanks a lot