Adding new records in Access without wrecking the form

Posted by Matt Parker on Stack Overflow See other posts from Stack Overflow or by Matt Parker
Published on 2010-04-05T20:38:52Z Indexed on 2010/04/05 20:43 UTC
Read the original article Hit count: 179

Filed under:
|
|

I'm working on a simple Access 2003 application to keep track of things that need to be done for clients for some colleagues. Each colleague has a set of clients, and each client has a set of actions that need to be taken by a certain date. I've set up a form that consists of a combobox for client ID (indexed), a drop-down for the person who is handling that client's case, and a button for adding new clients (a standard Access-created Add Record button). The actions are listed in a subform below these three elements.

The problem I've run into is that the first person I tested this on clicked the button to add a new record, then didn't fill it out and tried to select another client from the drop-down list. Access interprets this as an attempt to set the selected Client ID as the ID for the new record and rightfully throws an error for duplicate primary keys. I can think of a couple of ways around this problem, but I'd much rather hear your elegant solutions than kludge together some junk in a language I don't know.

Let me know if you have any questions. Thank you.

© Stack Overflow or respective owner

Related posts about ms-access

Related posts about forms