Adding when not in list

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

When a user enters an item not in the drop down list, how can I have it such
that the system asks if they would like to add the choice, opens a form
from that underlying subtable that allows the user to enter some additional
informaiton about the item they are adding, and then returns them to the
original form with the datasource updated so that it knows the new entry is
now in the list?

Thanks

- joe
 
You need to code the NotInList eventhandler along the lines of
Private Sub YourCombo_NotInList(NewData As String, Response
As Integer)


If MsgBox("Do You Wish to continue with new Value for
'Combo Data Type'", vbYesNo) = vbYes Then
DoCmd.OpenForm "YourFormName", acViewNormal, , ,
acFormAdd, acDialog, NewData
Response = acDataErrAdded
Else
YourCombo.Undo
Response = acDataErrContinue
End If

End Sub

The form is opened modal so that the information may be
added to the relevant table before the Response parameter
is set. The NewData is passed as the OpenArgs so that it
can be used in the form without the user having to enter it
again.

Hope This Helps
Gerald Stanley MCSD
 
Back
Top