Customer Contacts Database

chriscook

Registered User.
Local time
Today, 09:33
Joined
Nov 24, 2014
Messages
30
Good Afternoon All,

I am trying to create a Contacts Database for my Work.

However I am having some slight issues linking the required fields.

I currently have a Customers form which will show all customers, but when you double click on the ID, it will take you a list of the branches of that customer.

I have 2 tables. tblMainCustomer and tblSubCustomer. They both have a unique ID's.

When you add a branch (subcustomer) I need it to automatically register which MainCustomer it is.

I believe I need some code on my Form to add a new branch. For it to enter the correct MainCustomerID on my tblSubCustomers table.

I have attached my database so far. Sorry if i haven't explained it very well. I am quite new to Access.

Thanks in advance for your help and suggestions.
 

Attachments

If the sub form is connected to the main form key via
Link parent fields,
Link child fields.

Then all you do is add records into the sub form and they automatically get the master key.
 
Hi,

Thanks for your quick response.

It is currently on another form. Is it not possible to do it this way?

Or does it need to be on a subform?
 
Have a google for Access sub forms and Master/Child sub form linking.

This would allow you to list the sub branches in a form within your existing customer form, and automatically allow you to add new ones without any code or cleverness.

If you get stuck come back and tell us what you've done and what isn't working.
 
Hi,

Thank you for your suggestion.

I have used subforms in previous databases. I understand that this would resolve my issue. Ideally i would like to keep it as 2 seperate forms, as per my attached database.

Is there anyway of doing this? If not i will have to use subforms.

Thanks!
 
The easiest way is probably to pass the ID to the other form using the OpenArgs property. Then set that as the default value for new records in that field. I would use something like this in the OnLoad event

Code:
If Not IsNull(Me.OpenArgs) Then
   Me.[I]YourIDControl[/I].DefaultValue = Me.OpenArgs
End IF
 

Users who are viewing this thread

Back
Top Bottom