Relationship in Form

PHP_Adam

New member
Local time
Today, 16:55
Joined
Feb 5, 2009
Messages
6
Hello,

I have two tables:
Contacts (id, name, email .......)
and
ContactsClients (id, contactid, name, email .......)

Its quite a simple database where I have a database of my contacts, and a relationship one to many to a database of my contacts clients.

I have created a form, to add my contacts. Now when I come to create a form for adding my Contacts Clients information in, I come to to the entering contactid and get stuck.

How can I get this information entered automatic? I want to go from viewing my contacts, click a button then starting adding contacts clients?

Is this possible, or do I have to each time adding a contact client select my contact from a dropdown?
 
Hello and welcome to the forums!

One method is you can pass the ID through OpenArgs. You can do a search in Access Help or your favorite search utility for that.

I am not sure of your implementation but if your add contact is a seperate form - then here is another method. You could have a control on your client form (hidden or visible) that has the client ID in it.

On the contact form, you could have another client ID control (hidden or visible) to store the foreign key. The default value for this control could be ...

Code:
= Forms!fClientFormName!txtControlNameWithClientID
Hope this helps,

-dK
 
Its quite a simple database where I have a database of my contacts, and a relationship one to many to a database of my contacts clients.

First I think you need to clarify the above statement. Do you, in fact, have two databases here? And if so, why?

Or by databases do you actually mean two tables in your single database?

If it's the latter, which it should be and I suspect it is, this is the classic scenario for a main form/subform. Your Contacts table would be the record source for your main form and the ContactsClients the record source for the subform.

Simply design your second form, and once you place it on the first form as a subforme wizard will ask you which fields to use to connect the two. Select the ID fields and Access will do the rest.

When you're on a given Contact's record in the main form, any new records entered in the subform will be given the same ID.
 

Users who are viewing this thread

Back
Top Bottom