So in my Access application, there’s a field where the user selects a name from a dropdown list, or types one. The list should return a number (the PersonID of the person selected, if in the People table) or a string (if entering the name of someone not in the DB).
This must be a fairly common requirement, but I don’t see any very simple way to do it. The way that first occurs to me is to have VBA code which, if the user types a name instead of selecting from the list, creates an entry in the People table for the new person and then returns his PersonID (newly assigned by AutoNumber). This would presumably involve a dialog interrogating the user for required information (e.g. phone number) about the new person.
Is there a better way? Thanks.
Use the NotInList event of the ComboBox. Here is a quick sample:
NOTES:
SELECT @@Identityinstead (Google for more info).