T
truepantera
I cannot figure out what is wrong with my code. I am trying to add a not in
the list entry to the original table which is the source of the combo box on
my form. The source table is "Nametech" which has the field "NameTech that
needs to be updated from the current form ""Internal Chart Audit" the combo
box name is "Technician_Name" Spot anything wrong with the coding?
Private Sub Technician_Name_NotInList(NewData As String, Response As Integer)
On Error Resume Next
Dim Db As Database, rs As Recordset
Dim strmsg As String
strmsg = "'" & NewData & "' is not in Current List"
strmsg = strmsg & "@Do you want to add them?"
strmsg = strmsg & "@Click Yes to link or No to Cancel."
If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("[Nametech]", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Technician_Name = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
End Sub
the list entry to the original table which is the source of the combo box on
my form. The source table is "Nametech" which has the field "NameTech that
needs to be updated from the current form ""Internal Chart Audit" the combo
box name is "Technician_Name" Spot anything wrong with the coding?
Private Sub Technician_Name_NotInList(NewData As String, Response As Integer)
On Error Resume Next
Dim Db As Database, rs As Recordset
Dim strmsg As String
strmsg = "'" & NewData & "' is not in Current List"
strmsg = strmsg & "@Do you want to add them?"
strmsg = strmsg & "@Click Yes to link or No to Cancel."
If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new name?") = vbNo Then
Response = acDataErrContinue
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("[Nametech]", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Technician_Name = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
End If
rs.Close
Set rs = Nothing
End Sub