Subform not allowing new record (1 Viewer)

gary.newport

Registered User.
Local time
Today, 04:33
Joined
Oct 14, 2009
Messages
79
I have a form which contains a subform. This form is purely for new records and so is set to only allow Additions as well as having Data Entry set to Yes.

Embedded in this form is a subform; which is also set to Additions and Data Entry (though I have tried Additions and Edits without Data Entry).

The form itself works fine but the subform does not offer the new record field for anyone to select from; therefore no new records in the subform can be created.

Why not?

********* Update *********

Okay, I realise that it is down to Data Entry and that there is, on opening the form, no value within the primary field (obviously until the form starts to be completed). Where an existing value exists then the subform works (but no value can exist for a new record).

I am assuming that once someone selects a value within one of the fields and therefore the system generates a primary key value within the form, I will need to use VBA connected to the On Change of the primary key field that will create a new record within the subform, updating the subform to offer the fields for a new record to be entered.

Am I correct in my thinking and if so, any idea what the code would look like?

***** UPDATE 2 *****

If I run the form via the switchboard everything works fine; if I run the form directly then I have an issue (switchboard is set to run form in ADD mode). No idea why.
 
Last edited:

missinglinq

AWF VIP
Local time
Yesterday, 23:33
Joined
Jun 20, 2003
Messages
6,423
I have a form which... is set to only allow Additions as well as having Data Entry set to Yes.

If this means that you have the AllowEdits Property of the main form set to No this is what is causing your problem.The subform is actually a control on the main form, and doing anything to it, such as trying to add a record to the form that resides on the subform control, is considered, by Access, to be editing.

Change the main form's AllowEdits to Yes and you should be set! It won't matter on the main form; having Data Entry set to Yes prevents the user from editing old (existing) records anyway.

The reason it works from the Switchboard is that it opens the form, as you stated, in the AddMode, and this mode also allows editing.
 

Users who are viewing this thread

Top Bottom