I am getting a type-mismatch error in the coding below at the line Set rst = db.OpenRecordset("tblProspect"):
Private Sub CmbProspect_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As Recordset
Dim db As Database
strMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Company") Then
Response = acDataErrContinue
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblProspect")
rst.AddNew
rst!ProspectName = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
Any thoughts would be greatly appreciated.
Thanks.
Private Sub CmbProspect_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As Recordset
Dim db As Database
strMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Company") Then
Response = acDataErrContinue
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("tblProspect")
rst.AddNew
rst!ProspectName = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
Any thoughts would be greatly appreciated.
Thanks.