R
Roberta
Hello and thanks, in advance, for any thoughts you may be
able to offer on this issue.
I am attempting to update a table based on form input via
combo box. My problem is that, while it appears that
I've designated everything correctly, I'm still getting
an Type Mismatch error when it tries to add the new
record. The table (Key Word Options) is where I would
like the new data to reside in the Keyword field. Both
target and source fields are text.
I pulled this code off the knowledge base and my
modifications worked until the adding the record section.
Private Sub Keyword_NotInList(NewData As String, _
Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
On Error GoTo Err_Keyword_NotInList
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not in the list." & vbCr
& vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Key Word Options",
dbOpenDynaset)
Rs.AddNew
Rs![Keyword] = NewData
Rs.Update
Response = acDataErrAdded
End If
Exit_Keyword_NotInList:
Exit Sub
Err_Keyword_NotInList:
MsgBox Err.Description
Response = acDataErrContinue
End Sub
able to offer on this issue.
I am attempting to update a table based on form input via
combo box. My problem is that, while it appears that
I've designated everything correctly, I'm still getting
an Type Mismatch error when it tries to add the new
record. The table (Key Word Options) is where I would
like the new data to reside in the Keyword field. Both
target and source fields are text.
I pulled this code off the knowledge base and my
modifications worked until the adding the record section.
Private Sub Keyword_NotInList(NewData As String, _
Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
On Error GoTo Err_Keyword_NotInList
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not in the list." & vbCr
& vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Please try again."
Else
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Key Word Options",
dbOpenDynaset)
Rs.AddNew
Rs![Keyword] = NewData
Rs.Update
Response = acDataErrAdded
End If
Exit_Keyword_NotInList:
Exit Sub
Err_Keyword_NotInList:
MsgBox Err.Description
Response = acDataErrContinue
End Sub