Form won't allow add new record from combo box

  • Thread starter Thread starter Tony Wainwright
  • Start date Start date
T

Tony Wainwright

Hi Guys

I have created a form with sub form using the wizard. The main form has 1
field (HospitalId) linked to table tblHospital. The sub from contains 3
fields (WardId, WardName and Beds) from table tblHospitalWard. If I
navigate the main form by the navigation buttons I can add, delete and edit
records in the subform. However I want to navigate by means of using a
combo box on the main form. I have changed the text box on the main form to
a combo box, but when I change hospitals and try click in an empty field to
input data I get:

The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key or relationship.
Change the data in the field or fields that contain the duplicate data....

Even if I try to click in an existing record I want to edit I get the same
message. This is purely a wizard created form, there CBF at all.

Any ideas would really help
Thanks
Tony
 
Tony Wainwright said:
Hi Guys

I have created a form with sub form using the wizard. The main form has 1
field (HospitalId) linked to table tblHospital. The sub from contains 3 fields
(WardId, WardName and Beds) from table tblHospitalWard. If I navigate the
main form by the navigation buttons I can add, delete and edit records in the
subform. However I want to navigate by means of using a combo box on the main
form. I have changed the text box on the main form to a combo box, but when I
change hospitals and try click in an empty field to input data I get:

The changes you requested to the table were not successful because they would
create duplicate values in the index, primary key or relationship. Change the
data in the field or fields that contain the duplicate data....

Even if I try to click in an existing record I want to edit I get the same
message. This is purely a wizard created form, there CBF at all.

A ComboBox is typically used to enter data OR to navigate. You can't use it to
do both at the same time. If you had a TextBox bound to the HospitalId and
changed that to a ComboBox then making a choice in that ComboBox is editing the
current record (not what you want).

Change that back to a TextBox and then add a NEW ComboBox to the form making
sure that the Toolbox wizard is enabled. One of the choices from the ComboBox
wizard will produce a ComboBox for you that will navigate to different records.
That ComboBox will NOT be bound to any field and will not affect the current
record's data when you use it.
 
Hi tony,

Make sure the combobox is unbound -- if there is something
in the ControlSource property of your lookup combo, then
delete it

If all the main form has is the HospitalID field -- for
purposes of looking up a hospital and not for adding or
changing, the main form should not be bound either --
RecordSource property

Warm Regards,
Crystal
MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com
*
Have an awesome day ;)
 
Back
Top