On Not In List Problem

  • Thread starter Thread starter Rod via AccessMonster.com
  • Start date Start date
R

Rod via AccessMonster.com

Okay, I currently have a form consisting of 25 unbound combo boxes.
After data is entered into all of these combo boxes, there's a button
at the bottom of the form coded to enter the info into different tables.
For all of the new data entered, the "On Not In List" event runs. The
code in one of these events is as follows:

Private Sub Album_NotInList(NewData As String, Response As
Integer)
Response = acDataErrContinue
varUpdate3 = 1

End Sub

Now, when I run the form, the form will stop at any "On Not In List"
event and I cannot tap out of it. Since this form is used strictly for
data
entry, I don't want to display a message (of any kind) such as "Do you
want to add this info?" since that is the obvious intention.

Could someone assist in any additional code that is needed to get
out of the "On Not In List" event? Thanks
 
Rod via AccessMonster.com said:
Since this form is used strictly for
data
entry, I don't want to display a message (of any kind) such as "Do you
want to add this info?" since that is the obvious intention.

Could someone assist in any additional code that is needed to get
out of the "On Not In List" event? Thanks

If you just want to add the new data to the combo's row source then you need
something like this:

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

Dim db As DAO.Database, rs As DAO.Recordset, strSQL As String
Set db = CurrentDb
strSQL = "Select MyLookField from qcboMyLookupTable"
Set rs = db.OpenRecordset(strSQL)
With rs
.AddNew
![MyLookField] = NewData
.Update
End With
rs.Close
Set rs = Nothing
db.Close
Response = acDataErrAdded

End Sub

HTH - Keith.
www.keithwilby.com
 
Rod said:
Okay, I currently have a form consisting of 25 unbound combo boxes.
After data is entered into all of these combo boxes, there's a button
at the bottom of the form coded to enter the info into different tables.
For all of the new data entered, the "On Not In List" event runs. The
code in one of these events is as follows:

Private Sub Album_NotInList(NewData As String, Response As
Integer)
Response = acDataErrContinue
varUpdate3 = 1

End Sub

Now, when I run the form, the form will stop at any "On Not In List"
event and I cannot tap out of it. Since this form is used strictly for
data
entry, I don't want to display a message (of any kind) such as "Do you
want to add this info?" since that is the obvious intention.

Could someone assist in any additional code that is needed to get
out of the "On Not In List" event? Thanks


If the NotInList event is getting in the way, you might want
to consider not using it. You could use the AfterUpdate
event instead.

For your simple example, the AfterUpdate event would be

Private Sub Album_AfterUpdate ()
If Me.Album.ListIndex = -1 Then
varUpdate3 = 1
End If
End Sub
 
Back
Top