views:

57

answers:

2

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.

+2  A: 

Do not use the same control for data entry and navigating. it is sure to confuse. Create a textbox for entering new client IDs and change the combo so that it is no longer bound to the client id field (column).

Remou
And just to be sure I'm following you: I would then rewire the add new client button from its current function of creating a new, blank record to one in which it would create a new record from the contents of the Client ID textbox and the ID of the person in charge of that client - correct?
Matt Parker
That would certainly be one way.
Remou
+1  A: 

One key user interface principle that many people seem to miss:

Don't allow the user to do something you don't want them to do.

Now, in your case, based on how you've described things, I agree with @Remou that you need separate combo boxes, one for navigation, one for assigning the client.

But if for some reason you really need to do what you describe, the key is to disable the client combo box until the record is saved. So in the code behind your Add New command button, you'd set the combo box's .Enabled property to false. In the form's AfterInsert event, you'd set it back to True.

The idea is simply to make it imposslble for the user to do the wrong thing.

Sounds simple, but it's much harder to do than it sounds, since as the programmer you almost always have a perspective that prevents you from seeing your user interface the same way the user does. This is why I always say that in any of applications there are as many bugs left to be found as there are users who haven't tried it yet.

David-W-Fenton
I'm very much aware and in agreement with that principle - since I'm development and support rolled into one, I'd much rather not have to explain the correct order of button presses to create a new client several hundred times. It should just work for users. Thanks for your answer - I definitely don't really need it to work with just the combo box, but I might experiment with your suggestion anyway.
Matt Parker