P
poucedeleon via AccessMonster.com
I have created a main form and subform and want to prevent Access from adding
new data into the subform until I've entered key data, like a Primary Key
(AutoNumber), into the main form. I have a main form with Writeup information
and a subform with Officer information. I don't want new Officer data entered
until there's an associated Writeup record. It's my understanding, when you
enforce referential integrity between the underlying tables, Access prevents
you from entering orphan records. However, it only prevents this AFTER you've
typed in the data. This is very frustrating. What I would like to accomplish
is to prevent additions to the subform entirely, until you've entered the key
value into the main form. I have tried to accomplish this by taking advantage
of the form's AllowAdditions property. Toggle this property on and off
depending on the null state of the key field. Using my Writeup/Officer
example, in the main form's Current event procedure, I've entered the
following code statement
[sfrWriteUpStaffInvovled].AllowAdditions = Not IsNull([WriteupID])
When the CustomerID field is null, this statement evaluates as follows
[sfrWriteUpStaffInvovled].AllowAdditions = Not IsNull(Null)
[sfrWriteUpStaffInvovled].AllowAdditions = Not True
[sfrWriteUpStaffInvovled].AllowAdditions = False
Problem: I get a complie error "Method or Data Member not found".
Can someone give me some advise as to what I have done wrong.
Kevin
new data into the subform until I've entered key data, like a Primary Key
(AutoNumber), into the main form. I have a main form with Writeup information
and a subform with Officer information. I don't want new Officer data entered
until there's an associated Writeup record. It's my understanding, when you
enforce referential integrity between the underlying tables, Access prevents
you from entering orphan records. However, it only prevents this AFTER you've
typed in the data. This is very frustrating. What I would like to accomplish
is to prevent additions to the subform entirely, until you've entered the key
value into the main form. I have tried to accomplish this by taking advantage
of the form's AllowAdditions property. Toggle this property on and off
depending on the null state of the key field. Using my Writeup/Officer
example, in the main form's Current event procedure, I've entered the
following code statement
[sfrWriteUpStaffInvovled].AllowAdditions = Not IsNull([WriteupID])
When the CustomerID field is null, this statement evaluates as follows
[sfrWriteUpStaffInvovled].AllowAdditions = Not IsNull(Null)
[sfrWriteUpStaffInvovled].AllowAdditions = Not True
[sfrWriteUpStaffInvovled].AllowAdditions = False
Problem: I get a complie error "Method or Data Member not found".
Can someone give me some advise as to what I have done wrong.
Kevin