"New Record" button to subform or other table

Lancer

Registered User.
Local time
Today, 00:44
Joined
Jan 29, 2003
Messages
33
Question:
How do I make a form with an "Add Record" button which creates a new record on a subform?


Example:

Let's say I want to make a "Christmas Shopping Wishlist" for several clients...

First I have a table of clients...
Table: Client
[clientID] (AutoNumber) This will be associated to [clientLink] below...
[clientName] (Text)

And I have a form to create a Christmas shopping list for each person

Table: WishList
[giftID] (AutoNumber) ID number for each item
[clientLink] (number) - link to [clientID] the gift "belongs" to (e.g: who wants it)
[gift] (text) - Literal name of what they might like.


So far so good :) Now - I've already added three clients to my "Client" table; Melissa, Simon and Rachael.

Now for the difficult part... How do I make a form, which has...
* a pulldown combobox of [Client] (choose a name)
* a text box for [gift] where I get to type in a new item
* an "Add item" button which enters the data as a new item for the [gift] table each time it is pressed (repeats are allowed if it makes things easier.)
* A subform showing either the full table of the shopping list (all clients) or maybe just a query showing the list for whichever client is currently chosen in the [Client] combobox.

I hope I've written that clearly. The real example I want to use this with is rather complicated. The part I don't get is making the "New Record" button update fields in another table.
 
I think you need a third table with at least two fields as foreign keys refering to the previous described tables. With this constellation it is possible that one wish can be expressed by more than one client without having redundant data.

It is a matter of taste how to implement this Structure in a form. You can base the main form on the client or the wishlist table. The formerly mentioned table will reside then in a linked subform.

In the subform you could use a combobox for either the giftid or the clientid (You need only one). In the NotInList Event you can do data adding. I assume (I'm not sure) that you can find code for that intention by doing a search here on the forum.
 
Sorry, I think you kind of lost me. Also I have searched the forum. Most answers with the right keywords are so complicated I'm not sure they're on track, or are simple enough, but don't do what I'm wanting.

I'm attaching a simplified version of the problem. Please take a look. If you can get the button to work on either of the "newapproach" forms, then the problems should be resolved.

If there are several ways of doing this, I wuld like to know them so I can decide what will work on my bigger, more complex, database.

Hope we can solve it
 

Attachments

Users who are viewing this thread

Back
Top Bottom