REQ Help: Adding record to a table that is related to a selected record

  • Thread starter Thread starter Peppie
  • Start date Start date
P

Peppie

Hi,

I have a table that contains the address data of my clients. I
have another table that contains project data. It is related to
my clients table. 1 client can have multiple projects.

Now I made a form that shows 1 client at the time and I can
search for clients, add new clients, delete clients (who wants
to do that though) and so on. The form also show a sub-form for
all the projects that belong to one client. Here comes my
question: How can I create a button in my form that adds a
project to the selected client?

Can someone please help?

Regards, Peppie
 
Peppie,

I am not sure I understand. Why can't you add a new record on the
subform? Is the subform a Single view or Continuous view form? Does
the subform correctly show the Projects associated with the current
Ciustomer record on the main form? Can you see a new blank record on
the subform?
 
Steve Schapel wrote:

I am not sure I understand. Why can't you add a new record on
the
subform? Is the subform a Single view or Continuous view form?
Does
the subform correctly show the Projects associated with the
current
Ciustomer record on the main form? Can you see a new blank
record on
the subform?

Steve,

When I'm in the form which represent my clients, I would like to
have a button there that allows me to add a project to the
client I have selected at that moment. I can do this in the
subform, but I disabled that. The reason to disable that is that
the subform only shows some limited information from the
project-table (only projectnumber and name) The project table
however needs to be filled with more data. I can make a button
that opens an other form (project-form). However, I can not save
the data I entered, because it needs a referal to a ClientID
(which is an autonumber from the Client table and the link with
the project table).

What I need is that the button automatically copies the ClientID
from the selected record from the Client database into the
projectdatabase and that the Project-form allows me to fill out
the rest of the data.

This way, all new projects are automatically linked to the right
Client.

I would also like to make a similar button that allows me to add
contacts to a Client. The way my form is built now is that it
shows the general contact information of a Client (company). In
a subform, it shows all the contacts (persons) that belong to
that client. And of course the project-subform). It is all shown
on one page.

I hope you (or others) can be of help.

Thanks, Peppie
 
Peppie,

There are a number of approaches that can be taken here.

I guess the most common approach would be to simply have a combobox on
the Project form, where you can select the Client, thereby "manually"
entering the ClientID to the Projects table for the new project record.

If you will *always* be entering a new Project record, via opening the
Projects form from a button on the Clients form, then you could set the
Default Value property if the ClientID control on the Projects form to
the equivalent of this...
[Forms]![Clients]![ClientID]

Otherwise, you could use a SetValue action, in the macro that opens the
Projects form, to set the value of the ClientID control to the ClientID
on the Cleitns form.
 
Thank you Steve.

Setting the default value to the selected Client record works
great.

With kind regards, Peppie
 
Back
Top