hiiiiii all dears
i have main form and a subform
i use a code in the sub form in BeforeInsert event as :
to prevent user to add non-related sub record .
this works good if the primary key (ID) is autonumber only.
but if the primary key (ID) is a number or text it not works good ?
please help .
i have main form and a subform
i use a code in the sub form in BeforeInsert event as :
Code:
Dim frm as Form
Set frm = Me.Parent
If IsNull(frm.[ID]) Then
Cancel = True
MsgBox "Create a record in the main form first.", vbExclamation, "Required data."
frm.[ID].SetFocus
End If
this works good if the primary key (ID) is autonumber only.
but if the primary key (ID) is a number or text it not works good ?
please help .