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
 
Back
Top