Unanswered: How can I add data to a list when using a combo box search?
Hi all, I am a real novice with Access 2003 so please be gentle.
I have a form (dogs) within which are the sire and dam of each dog. I have set up a combo box search that links to a table "sire" and a table "dam". How do I get a new sire or dam added to the relevant table if it isn't in the combo box list? I have tried changing the properties of the combo box event tab for "if not on list" but obviously it isn't working otherwise I wouldn't be asking for help.
Besides setting the if not in list property, you also need to set the "Limit To List" property to "Yes". Once that's done, set the if not in list property to an [Event Procedure], and write a VBA procedure to add the name to the appropriate table.
Thanks Sam, but as I said I am a real novice. I have changed Limit to List to yes but really don't know how to write the Event Procedure. My "sire" table has two columns "Registration No" and "Name" if you could help again I'd really appreciate it.
I'll try, Kim, but the best way to learn to swim is to get in the water and flex the proper muscles.
Open the form in design mode. If the Properties box is not visible, right click anywhere on the form and select Properties. Click in the combo box (again, anywhere). In the property sheet, which reflects all properties of the combo box, scroll to On Not In List and click in the box. Click on the elipsis (...). In the dialog box, select Code Builder. This opens the VBA editor, with the beginning and end of your new procedure.
Put code in here to
1) Ask the user if he's sure he wants to add a new sire (or dam, if it's the female's combo box). Use the MsgBox() function for that.
2) If not, return him to the combo box to enter a new name.
Please use the help file liberally. That's what it's there for. Specifically, read up on the use of forms and the VBA behind the forms. You'll also want to read up on the MsgBox() function mentioned above.