Customizing limit to list

mlopes1

Registered User.
Local time
Today, 07:33
Joined
Sep 4, 2002
Messages
76
Can I change message appears when someone enters something in a combo box that isn't the list... right now says just "The Text You Entered...". How do I customize? Thanks as always!

Marco
 
The following will warn you that you are entering a choocie that is not in the list. I will allow you to continue and enter the new choice. It updates the undelying table.
If you do not like them to enter a new choice, just take that part out.

Set the Limit To List property of your combo box to YES
In the OnNotInList event procedure insert the following code

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

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

If MsgBox("You entered a value that is not in the list. Would you like to continue and add it?", vbYesNo + vbDefaultButton1 + vbExclamation, "Add New Value?") = vbYes Then


Set db = CurrentDb
Set rs = db.OpenRecordset("tblYourTableName")
With rs
.AddNew
!SubjectName = NewData
.Update
.Close
End With
Response = acDataErrAdded
Else
MsgBox "Clear your entry or select a value from the list.", vbOKOnly, "Addition cancelled"
Response = acDataErrContinue
End If
Set rs = Nothing
End Sub
 

Users who are viewing this thread

Back
Top Bottom