hi everyone -
i am making a db that has the names of paintings. some paintings would come out Hunting Scene (generic) or specific - "The Hunter's Scene". So while I have been able to find solutions for dealing with EITHER apostrophes OR double quotes, i can't find one that will work with both. i am very much the novice at this and just doing this for fun.
i have tried using a public const QUOTE as suggested elsewhere on this forum, using the REPLACE function, using Chr(34) etc, setting Dim DQ as String and defining as Chr$(34), etc etc. i can't get anywhere.
here is the code i'm using. i got the original code from Martin Green's site which i've seen ref'd here a number of times.
this is the not-messed-with code for this field. this is exactly what i have for every other field and it works just fine (of course, no quotes or apostrophes).
---------------------------------------------------------------
Private Sub TitleID_NotInList(NewData As String, Response As Integer)
On Error GoTo TitleID_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The title " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Paintings Inventory")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tblTitle([Title]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded
Else
MsgBox "Please choose a title from the list." _
, vbInformation, "Painting Inventory"
Response = acDataErrContinue
End If
TitleID_NotInList_Exit:
Exit Sub
TitleID_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume TitleID_NotInList_Exit
End Sub
------------------------------------------------------
thanks a bunch for any help! i've spent the last five hours on the webbie web looking for answers and going through 2 access books and one on access vba. i'd think this was a more common problem! or i'm just missing something basic

mol
i am making a db that has the names of paintings. some paintings would come out Hunting Scene (generic) or specific - "The Hunter's Scene". So while I have been able to find solutions for dealing with EITHER apostrophes OR double quotes, i can't find one that will work with both. i am very much the novice at this and just doing this for fun.
i have tried using a public const QUOTE as suggested elsewhere on this forum, using the REPLACE function, using Chr(34) etc, setting Dim DQ as String and defining as Chr$(34), etc etc. i can't get anywhere.
here is the code i'm using. i got the original code from Martin Green's site which i've seen ref'd here a number of times.
this is the not-messed-with code for this field. this is exactly what i have for every other field and it works just fine (of course, no quotes or apostrophes).
---------------------------------------------------------------
Private Sub TitleID_NotInList(NewData As String, Response As Integer)
On Error GoTo TitleID_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The title " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Paintings Inventory")
If intAnswer = vbYes Then
strSQL = "INSERT INTO tblTitle([Title]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
Response = acDataErrAdded
Else
MsgBox "Please choose a title from the list." _
, vbInformation, "Painting Inventory"
Response = acDataErrContinue
End If
TitleID_NotInList_Exit:
Exit Sub
TitleID_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume TitleID_NotInList_Exit
End Sub
------------------------------------------------------
thanks a bunch for any help! i've spent the last five hours on the webbie web looking for answers and going through 2 access books and one on access vba. i'd think this was a more common problem! or i'm just missing something basic
mol