Pete:
Put a button beside the Course combobox and label it Add New Course. Put the
following code in the Click event of the button:
DoCmd.OpenForm "NameOf formToAddCourses",,,,,acDialog
If Not IsLoaded("NameOf formToAddCourses") Then
Exit Sub
End If
Me!NameOfCourseCombobox.Requery
Me!NameOfCourseCombobox = Forms!NameOf formToAddCourses!CourseID
DoCmd.Close acForm, ("NameOf formToAddCourses"
Notes:
1. Put an OK button on your form to add courses and put code in the Onclick
event to make the form not visible.
2. The IsLoaded function is in a standard module in Northwind.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
resource@pcdatasheet.com www.pcdatasheet.com
"Pete" <pshappyman@zombieworld.com> wrote in message
news:988f1cfc.0401120937.52a87303@posting.google.c om...[color=blue]
> I'm currently doing a database that uses comboboxes to look up records
> in other tables, whether they be lookup tables or otherwise. When a
> user needs to add an item to one of these tables, the user has to
> either double-click on the combobox or go to the appropriate form via
> an item on the main menu.
>
> So, using an example, if someone is entering enrollment information,
> they would definitely need a student and a course. If the course has
> not been entered as a row in the "tblCourses" table yet, they could
> double-click on the course combobox, which brings up the Course
> Information form (modal). Then they enter the information, close the
> Course Information form, and the combobox is requeried.
>
> I am using all bound forms.
>
>
> I know that it's possible to add items to simple lookup tables using
> code and the NotInList() event. I think there have been recent
> threads similar to this vein. But what about more complex lookups,
> like the Course info? Courses have start dates, end dates, costs,
> trainers, etc.
>
> There are many ways to achieve something akin to AutoComplete by
> allowing the ability for users to natively enter data in the 'main'
> enrollment form, check to see if a course matching the typed info
> exists, and if so, just set the foreign key equal to whatever matched.
> Or, if nothing similar exists, then create a new course, get the ID,
> and store that in the 'main' form.
>
> So back to example--you enter in "12-10-2000" for the start date. Tab
> over, which causes the AfterUpdate() event, which sees only one
> matching course for that date. Since there's only one course, it
> fills out the rest of the information for you and stores the ID of
> this course.
>
> Another--you enter in "12-11-2000" for the start date. Tab over.
> "Billg" is the trainer. Tab over. Etc. Tab. Etc. You update the
> last field, and it notices that (1) all fields are filled in, and (2)
> there is no matching course. So it creates a record in the table. It
> then stores this record in the enrollment information.
>
>
> Now for my question: has anyone actually implemented something like
> this? If so, was it worth the hassle? Or is there a simpler way, or
> am I doing it correctly right now (see paragraph 1)? I'm just looking
> for a word of experience telling me that this is a (1)good idea, or
> (b)bad idea, or (e)all of the above. This is an Access-specific
> question because it involves questions about using bound forms, doing
> multiple and possibly frequent lookups, and because I'm using Access
> 97 for all this.
>
>
> Pete[/color]