G
Guest
Hi, I am a newbie to access. I have a combox that is that is bound to an
employee table. I have a another table called supervisor, it has supervisor
last name and autonumber
When the combo is clicked on it has a possible of supervisors. I just want
it to also add a supervisor name into the list and table. I looked online and
found this code:
Private Sub combo1_NotInList(NewData As String, _
Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Dim NewID As String
On Error GoTo Err_combo1_NotInList
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Confirm that the user wants to add the new requester.
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
' If the user chose not to add a requester, setthe Response
' argument to suppress an error message and undochanges.Response =
acDataErrContinue
' Display a customized message.
MsgBox "Please try again."
Else
' If the user chose to add a new requester, open aRecordset
' using the CHANGE#LOG table.
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Supervisor", dbOpenDynaset)
' Assign the NewData argument to the REQUESTERfield.
Rs![CHANGE#LOG] = NewData
' Save the record.
Rs.Update
' Set Response argument to indicate that new datais being added.
Response = acDataErrAdded
End If
Exit_REQUESTER_NotInList:
Exit Sub
Err_REQUESTER_NotInList:
' An unexpected error occurred, display the normalerror message.
MsgBox Err.Description
' Set the Response argument to suppress an errormessage and undo
' changes.
Response = acDataErrContinue
End Sub
When I enter new data it does not input it in. Any help would be appreciated.
employee table. I have a another table called supervisor, it has supervisor
last name and autonumber
When the combo is clicked on it has a possible of supervisors. I just want
it to also add a supervisor name into the list and table. I looked online and
found this code:
Private Sub combo1_NotInList(NewData As String, _
Response As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String
Dim NewID As String
On Error GoTo Err_combo1_NotInList
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Confirm that the user wants to add the new requester.
Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
' If the user chose not to add a requester, setthe Response
' argument to suppress an error message and undochanges.Response =
acDataErrContinue
' Display a customized message.
MsgBox "Please try again."
Else
' If the user chose to add a new requester, open aRecordset
' using the CHANGE#LOG table.
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("Supervisor", dbOpenDynaset)
' Assign the NewData argument to the REQUESTERfield.
Rs![CHANGE#LOG] = NewData
' Save the record.
Rs.Update
' Set Response argument to indicate that new datais being added.
Response = acDataErrAdded
End If
Exit_REQUESTER_NotInList:
Exit Sub
Err_REQUESTER_NotInList:
' An unexpected error occurred, display the normalerror message.
MsgBox Err.Description
' Set the Response argument to suppress an errormessage and undo
' changes.
Response = acDataErrContinue
End Sub
When I enter new data it does not input it in. Any help would be appreciated.