I have looked at every post I can find and cannot seem to find code for the NotInList event where it will update more than one field in my table. Here is what I have used from the forum so far.
I have tables named Documents and Combined. Combined shows each employee record and the Documents assigned to them. My form Add Records which is opened via a command button on my main form is as follows: EEID (bound to Combined) DocID(bound to Combined) Revision(unbound) Description(unbound) and TrainingType (rowsource is tblType). The NotInList Event updates my table Combined perfectly, but only updates field DocID (which is where the NotInList event is) in my Documents table. I am trying to avoid having a separate pop up form to add new items.
Private Sub DocID_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As DAO.Recordset
Dim db As Database
trMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Record") Then
Response = acDataErrDisplay
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("Documents")
rst.AddNew
rst!DocNumber = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
Any help would be appreciated.
Toni
I have tables named Documents and Combined. Combined shows each employee record and the Documents assigned to them. My form Add Records which is opened via a command button on my main form is as follows: EEID (bound to Combined) DocID(bound to Combined) Revision(unbound) Description(unbound) and TrainingType (rowsource is tblType). The NotInList Event updates my table Combined perfectly, but only updates field DocID (which is where the NotInList event is) in my Documents table. I am trying to avoid having a separate pop up form to add new items.
Private Sub DocID_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As DAO.Recordset
Dim db As Database
trMsg = "'" & NewData & "' is not in the list. "
strMsg = strMsg & "Would you like to add it?"
If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
"New Record") Then
Response = acDataErrDisplay
Else
Set db = CurrentDb()
Set rst = db.OpenRecordset("Documents")
rst.AddNew
rst!DocNumber = NewData
rst.Update
Response = acDataErrAdded
rst.Close
End If
End Sub
Any help would be appreciated.
Toni