Referential Integrity - Form error

  • Thread starter Thread starter rblivewire
  • Start date Start date
R

rblivewire

I have a form with 1 subform. I have a one to many relationship with
referential integrity. The field that is connected is an autonumber.
My only problem is if the user clicks on any option on the subform, now
they cannot enter any information into the options on the main form. I
get the "you can't add or change a record because a related record is
required" error. Is there any way around this error?
 
Use the events on your main form to enable/disable the subform as required.

In the Current event, disable the subform if you are on a new record.

In the BeforeInsert event, enable the subform again.

Private Sub Form_Current()
Me.[SubformControlName].Enabled = Not Me.NewRecord
End Sub


Private Sub Form_BeforeInsert(Cancel As Integer)
Me.[SubformControlName].Enabled = True
End Sub
 

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

Back
Top