not allow data in sub-subform until subform field has data

D

deb

I have a form called fProjectReview and a subform called fWarranty with a
sub-subform called fWarrantyDetails.

If a user fills out any of the fields in the sub-subform before they enter
data into the "required field" called WarrantyPCT in the subform, they
receive an error "Index or primary key cannot contain a null value" and the
only way out is to close the form and loose all data entered.

Is there a way to not allow data entered into the sub-subform until the
"required field" has data?
 
J

John Vinson

deb said:
Is there a way to not allow data entered into the sub-subform until the
"required field" has data?

One way would be to use a bit of VBA code to set the Enabled property of the
sub-subform to Yes in the subform's AfterUpdate event; also put code in the
subform's Current event to set it to No if the subform is empty. E.g.

Private Sub Form_Current()
Me!fWarrentyDetails.Enabled = (Me.RecordsetClone.RecordCount > 0)
End Sub
Private Sub Form_AfterUpdate()
Me!fWarrentyDetails.Enabled = (Me.RecordsetClone.RecordCount > 0)
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

Top