Form to add field data to an existing table row (1 Viewer)

gsandy

Registered User.
Local time
Today, 13:09
Joined
May 4, 2014
Messages
104
I have a form (frmCompany) which has two combo boxes (cmbCompany and cmbCity) which is used to add field data into a table (tblCompany). The Company field is the only required field the other is optional.

In some cases I may wish to add a City, at a later date, to an existing Company using frmCompany. I now select the company from the cmbCompany combo box then add the city to cmbCity. The problem is that when I close the form I get two companies in the table with same name, one has a city and one does not.

How can I add a new City to an existing Company, using the form, without adding a new Company? Thanks Sandy
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:09
Joined
Jan 20, 2009
Messages
12,852
You are adding a new record instead of updating an existing one.

I suspect your form is in DataEntry mode where it doesn't show the existing records. Have look at the Properties of the form.
 

gsandy

Registered User.
Local time
Today, 13:09
Joined
May 4, 2014
Messages
104
I am updating an existing record.
The cmbCompany combobox (in frmCompany) lists all the existing companies. So I select an existing company, select a City from cmbCity combo box and then close the form.
When I open tblCompany I have two companies, one with a city and one without a city. The one without a city is in a new row (the latest entry in the table). The City has been added to the existing company row.
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 11:09
Joined
Jan 20, 2009
Messages
12,852
There is clearly something seriously wrong with the design of the form.
 

smig

Registered User.
Local time
Today, 04:09
Joined
Nov 25, 2009
Messages
2,209
If you need to select a company from the list you are definetly not updating an existing record.
 

gsandy

Registered User.
Local time
Today, 13:09
Joined
May 4, 2014
Messages
104
Thanks Guys. It is quite possible that there is something wrong with the form or DB as it is my first attempt in the world of Access. I will attempt to find the error today and then go on my Christmas holiday until mid January.
 

gsandy

Registered User.
Local time
Today, 13:09
Joined
May 4, 2014
Messages
104
Hi Mihail, "Happy Christmas" or "Merry Christmas" are the English expressions, you will have to wait until next December to use it!

Thanks for the link regarding Normalization. Cheers Sandy
 

gsandy

Registered User.
Local time
Today, 13:09
Joined
May 4, 2014
Messages
104
Thanks to the article I think I have found the problem. I had a Many to Many relationship, so have added a join table.
 

Users who are viewing this thread

Top Bottom