View Full Version : Forms & sub forms visible


mark curtis
05-31-2001, 09:35 AM
Dear all,

I have a main form in datasheet view and a sub form linked to the main form, which is also in datasheet view.

What I want to do is make sure a user can not enter data in the subform related to record in the main form until the main form is populated.

I keep getting am error message about key violation, which i know is because a user is populating the related subform before the master form.

Any examples on which event I should use and what type of code would be much appreciated.

Thanks
Mark

Rich
05-31-2001, 02:33 PM
Use the on enter event of the subform to throw them back to the main form
If Me.Something = False Then
Beep
MsgBox "STOP database has detected that you are trying to enter a record etc."vbOKOnly, ""
DoCmd.CancelEvent
DataEntry = False
SendKeys "{ESC}", False
SomeMainFormField.SetFocus
End If
HTH