Cannot add record in subform

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Cannot add record in subform

Post by Pat »

I can add a record in the query behind the subform but cannot add a record in the subform.
In fact the first field in the subform is a combo box, it shows all entries but will not allow me to select one.
I initially had a cmpile error in the subform but have added those 2 fields.

Any ideas why it wont allow me to select an entry from the combo box?

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cannot add record in subform

Post by HansV »

Make sure that

1) The Locked property of the subform as a control on the main form has been set to No.
2) The Link Child Fields and Link Master Fields properties of the subform as a control on the main form have been set properly.
3) The Locked property of the combo box has been set to No.
4) The Recordset Type property of the subform itself has been set to Dynaset or to Dynaset (Inconsistent Updates).
5) The Allow Additions and Allow Edits properties of the subform have been set to Yes.
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Cannot add record in subform

Post by Pat »

All verified, however, when i try to add a record when the subform is independant of the main form it adds ok.
Does this mean my Child/Master links are the problem?
This field is a Foreign Key in the table behind the subform and is a field in the table behind the main form.
The BE is SQL Server.

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cannot add record in subform

Post by HansV »

If you can add a record when you open the subform by itself, the problem is with the subform as a control on the main form. If you have checked that it has not been locked, it looks like there is a problem with the link to the main form. Is the "master" field the primary key of the table behind the main form?
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Cannot add record in subform

Post by Pat »

It is now.
The combo box still does not allow me to select an item from it. If i delete the child/master links i can select a combo box entry and then create a record in the subform.
Weird eh

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cannot add record in subform

Post by HansV »

Does the problem also occur if the backend is an Access database?
Best wishes,
Hans

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Cannot add record in subform

Post by Pat »

I have found the problem, there was code in the Enter event of the subform that locked/unlocked all controls in the subform.
Sorry to waste your time.

User avatar
HansV
Administrator
Posts: 78531
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cannot add record in subform

Post by HansV »

No problem, glad you found it. Thanks for posting back.
Best wishes,
Hans