L
Lavatress
I have a combo box that looks up citation numbers from a field in my table
called TRBOOKS. I want the user to be able to add a citation number that is
not in the combo box. I reviewed some of the questions and replies
pertaining to the notinlist event. I used the following code in relation to
the notinlist event (see below). I have other fields on form such as: issue
date, receive date, and date forwarded. Also, I have a subform on my main
form which is called trsubform. My question is: when the user adds a new
citation, and moves to the next field/fields, how can this information be
updated in the table? Thanking you in advance.
Private Sub CITNUM_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the database." & vbCr & vbCr
Msg = Msg & "Do you want to add New Record?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TRBOOK", dbOpenDynaset)
rs.AddNew
rs![CITATION NUMBER] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub
called TRBOOKS. I want the user to be able to add a citation number that is
not in the combo box. I reviewed some of the questions and replies
pertaining to the notinlist event. I used the following code in relation to
the notinlist event (see below). I have other fields on form such as: issue
date, receive date, and date forwarded. Also, I have a subform on my main
form which is called trsubform. My question is: when the user adds a new
citation, and moves to the next field/fields, how can this information be
updated in the table? Thanking you in advance.
Private Sub CITNUM_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim Msg As String
Msg = "'" & NewData & "' is not in the database." & vbCr & vbCr
Msg = Msg & "Do you want to add New Record?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("TRBOOK", dbOpenDynaset)
rs.AddNew
rs![CITATION NUMBER] = NewData
rs.Update
Response = acDataErrAdded
End If
End Sub