i have a combo box that lists occupation descriptions, and it has a bound text box that displays its corresponding number. i want the user to be able to add a new occupation.
this is the code that i'm using to try to add a new record to my occupation combo box:
Private Sub occNum_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As Recordset
Dim db As Database
strMsg = "'" & NewData & "' is not in list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Service Code" Then
Response = acDataErrDisplay
Else
Set db = Final_Database()
Set rst = db.OpenRecordset("tblOccupation"
rst.AddNew
rst!occName = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
i don't know what i'm doing wrong. would really appreciate help on this. thank you.
this is the code that i'm using to try to add a new record to my occupation combo box:
Private Sub occNum_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As Recordset
Dim db As Database
strMsg = "'" & NewData & "' is not in list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Service Code" Then
Response = acDataErrDisplay
Else
Set db = Final_Database()
Set rst = db.OpenRecordset("tblOccupation"
rst.AddNew
rst!occName = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
i don't know what i'm doing wrong. would really appreciate help on this. thank you.