Not In List and Multiple Fields

thart21

Registered User.
Local time
Today, 02:12
Joined
Jun 18, 2002
Messages
236
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
 
If you want to update more than one field then it's a better idea, should the user wish to add the item, to open a form which will let them type/select/click etc. on the relevant details.
 
Thanks for the reply. I originally had a separate pop up form to add the details for a new record, but I had the issues I described in my earlier post on 3/22/04 "Open Args and Tabbed Subforms". I have used the pop up form successfully with just a main form and one subform, but when I imported the same code to my new db with tabbed subforms, it will not work.

Any ideas?

Thank you
 

Users who are viewing this thread

Back
Top Bottom