Combo Not in List Problem

  • Thread starter Thread starter Perico
  • Start date Start date
P

Perico

I have a form where the default view is datasheet (not
sure that matters.) One of the field controls is a combo
box. I use the standard "Not in List" code below. I
notice when I respond "yes" to add to the list, it works
fine, however after I enter the data in that first row and
I move to the next row, the data for that field is entered
again in the second row. What is causing this duplication?

Here's my code:

'Private Sub SchName_NotInList(NewData As String, Response
As Integer)
' Dim strMsg As String
''PROBLEM - THIS ADDS TWICE
' strMsg = "'" & NewData & "' is not in the list. "
' strMsg = strMsg & "Would you like to add it?"
' If vbNo = MsgBox(strMsg, vbYesNo + vbQuestion, _
' "New School") Then
' Response = acDataErrDisplay
' Else
' Dim rst As Recordset
' Dim db As Database
' Set db = CurrentDb()
' Set rst = db.OpenRecordset("tblSchool")
' rst.AddNew
' rst!SchName = NewData
' rst.Update
' Response = acDataErrAdded
' End If
'End Sub
 
Is the combo box unbound? If yes, all instances of the combo box will
display whatever is selected in one of the combo boxes. You must bind the
combo box to a field in the form's recordsource in order for it to hold
different values for each record.
 
Back
Top