ngreenleaf
Programmer
In a combo box is there a way to distinguish between a user typing in a null value and pressing enter, versus clicking on a list entry that is bound to a NULL value? I thought the ENTER versus CLICK events would distinguish these -- but apparently not.
Details: I have a combo box for a list of names -- a key value and a string value. The only value that can never occur in the list is NULL as it si a primary key. My combo box allows the user to select a name - or select a list item hardwired to the text "New. . .". But the "New. . ." list entry is bound to a NULL whereas the other list entries are bound to their name. It is valid for the user to choose no name. To do this the user must type a NULL (eg delete the characters on the line and press ENTER). It is initially set to NULL - so no selection works fine when creating the record... but if the user is updating an existing record this situation arises. I want to do one thing when the user clicks on "New. . ." and another thing when the user deletes the existing name.
I know one way (I think) - I can put an autonumber on the table and use it as the bound column... then I can use -1 (an invalid value for an autonumber) to bind to "New. . .". In this way NULL will be NULL and "New. . ." will be -1. I do not want to go this route if I do not have to. The name is a good natural key.
One other thought is to work with the keypress event -- this seems almost impossible -- to tell if the user pressed a key, then clicked something abandoning the typing... not sure if this route will work though. Ultimately I need to know if the action that got me to the procedure was pressing ENTER or clicking the mouse.
Details: I have a combo box for a list of names -- a key value and a string value. The only value that can never occur in the list is NULL as it si a primary key. My combo box allows the user to select a name - or select a list item hardwired to the text "New. . .". But the "New. . ." list entry is bound to a NULL whereas the other list entries are bound to their name. It is valid for the user to choose no name. To do this the user must type a NULL (eg delete the characters on the line and press ENTER). It is initially set to NULL - so no selection works fine when creating the record... but if the user is updating an existing record this situation arises. I want to do one thing when the user clicks on "New. . ." and another thing when the user deletes the existing name.
I know one way (I think) - I can put an autonumber on the table and use it as the bound column... then I can use -1 (an invalid value for an autonumber) to bind to "New. . .". In this way NULL will be NULL and "New. . ." will be -1. I do not want to go this route if I do not have to. The name is a good natural key.
One other thought is to work with the keypress event -- this seems almost impossible -- to tell if the user pressed a key, then clicked something abandoning the typing... not sure if this route will work though. Ultimately I need to know if the action that got me to the procedure was pressing ENTER or clicking the mouse.