Subform problem (error msgs when main form not filled out)

  • Thread starter Thread starter MarcoM
  • Start date Start date
M

MarcoM

Guest
Hi there,
i'm having a problem with subforms that some of you probably have encountered already, but i'm unable to find anything in the Help or on this board. Here it goes:

I made two tables and linked them via primary/foreign keys (a one to many relationship) and told access to enforce relational integrity.
Then i've got a form with a subform to input data into these tables. All works fine, but when i want to input a new record and start off typing in data into the subform, access complains that there is no ID from the main form it can link the data in the subform to.

So... What would be the best way to disable the subform until data has been entered into the main form, i.e there actually is an ID to link the data in the subform to ?

Thank you very much in advance for your time !

Bye, Marco
 
Use the before insert event of the subform
If IsNull(Me.IDName) Then
MsgBox"Oy Get Out"
SomeTxtBoxName.SetFocus
End If
 
Hi Rich,
thanks for your answer, it worked out just fine for me :-)
In case anyone is interested, i also added a cancel = true at the end of the function to clear the field again.

cya, marco
 

Users who are viewing this thread

Back
Top Bottom