How do I prohibit creation of new records in subform?

M

mjg

I have a main form w/ two subforms in Access. Based on their parent/child
fields, the subforms call-up existing matching records. My problem is: when
there is no matching record in my subform it automatically creates a new
record and populates it with whatever is entered in the parent field on the
main form. I would like the user to be able to add and edit records on the
main form regarless if there is a match on the subform or not. When there is
a matching child record in the subform, I would like the user to be able to
edit those fields.

I don't think I can use referential integrity to control this because my
main form has many (duplicate) records and this is the 'parent' field in the
link (i.e. a one-to-many relationship).

Any tips?
 
M

Maurice

My first hunch would say that the subform could be set to allow edits=true
and allow additions=false. You can set these properties in the form
properties of the subform.

hth
 
A

Allen Browne

There is something wrong with the subform if it is automatically creating
new record. The trick will be to identify what's doing that, and fix that
problem.

Typically you are looking for some code that assigns a value to a bound
control. It could be in the Current event of the form (the subform), or
perhaps the Enter event of the first control on that form.

To help you pin it down, set the form's RecordSelector property to Yes. This
shows a block to the left, the height of the record. When the form is
dirtied, the icon in the RecordSelector changes to a pencil to indicate
editing is in progress, so this may help you identify when it's being
dirtied.
 
M

mjg

Your solution worked! It ended up being slimpler than I'd anticipated -
thanks.

Now I'm trying to figure out how to get the tab-order to skip that subform,
but only when there is no matching record (nothing to edit).
-mjg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top