Combo Box/Add New Data/Requery

JeepsR4Mud

Registered User.
Local time
Yesterday, 20:33
Joined
Sep 23, 2002
Messages
70
Hello,

I'm working on an employee incident database. In my main form, which is the actual incident, I have a subform of employee information. One of the fields is a combo box that draws off of a query, which draws from a table called Staff Names. The query, staff name sort, sorts the employees by last, then first, names.

The fields are : ID, Last Name, First Name, Race, Gender.

I'd like a message box to appear when a new employee is entered, and the box to refresh, but.. I copied the following code from the archives, but... It works to the Yes/No question, then...

Ideally the form: Staff Name Entry Form would open when notinlist is triggered, info is added, and the combo box is refreshed.

I know it is routine, and not difficult. I just don't know how to do it.

Here is the code.

Thanks.

Gayle Ann

Private Sub QuestionNumber_NotInList(NewData As String, Response As Integer)

Dim db As DAO.Database, rs As DAO.Recordset

intAnswer = MsgBox(strMessage, vbQuestion + vbYesNo)

If MsgBox("'" & NewData & "' is currently not in your list." & vbCrLf & vbCrLf & _
"Do you wish to add it?", vbQuestion + vbYesNo) = vbYes Then
Set db = CurrentDb
Set rs = db.OpenRecordset("Staff Names")
With rs
.AddNew
.Fields("ID") = NewData
.Fields("Last Name") = NewData
.Fields("First Name") = NewData
.Fields("Race") = NewData
.Fields("Gender") = NewData
.Update
.Close
End With
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If

Set rs = Nothing
Set db = Nothing

End Sub



I've tried using a comand button, and I can get the info into the form, but I can't get the combobox to requery/refresh.

ANother used posted the solution to that problem today, I think, but I'd rather eliminate the command button and have it all driven from notinlist.

I'm a true novice at code. I tend to copy and fill in the blanks.

Thanks.

Gayle Ann
 

Users who are viewing this thread

Back
Top Bottom