making sure that parent form has records

lala

Registered User.
Local time
Today, 13:58
Joined
Mar 20, 2002
Messages
741
Hi, how do i make sure that parent form has a current record?

i have no problem doing it as long as the parentform has ALLOWADDITIONS enabled, but in my case it's disabled and i tried every trigger i can think of - and if there's no records in the parent - the user can still click the ADD button on the subforms and a new record will get created.

the problem exists when clicking on the ADD button on either the Buckets or the ClientCodes subform when the SLA Detail parent subform has no records

thank you very much!!
 

Attachments

Enable Referential Integrity in the relationship between the tables.
 
and also make the foreign key (the parent record's primary key) a required field in the child record, or else you might still be able to create orphaned records.
 
If the form is structured as a Form/Subform the only records that should be able to be entered are automatically related to the record in the parent form.

With the LinkMasterFields and LinkChildFields correctly set the PK of the parent is automatically entered as the FK in the subform. The FK doesn't even need to be displayed in the subform.
 
I can't enable referential integrity, these tables are linked from oracle.

So there's no way to know in vba that the parent form has no records? That's my problem, that even when there's no parent record - clicking ADD still creates a child record.
 
You could use a DLookUp to check there is a record in the parent table.
 
Even with the Oracle backend you should still be able to use a Form-Subform structure and disable AllowAdditions in the subform if there are no records in the main form.
 
Even with the Oracle backend you should still be able to use a Form-Subform structure and disable AllowAdditions in the subform if there are no records in the main form.

Yes, I was able to. I mentioned oracle when you suggested referential integrity - that I can't do with oracle.

So about the dlookup, I'm probably stalling, but what would I be searching for? Can you do it in my example?
 
maybe look at how you get a situation where you can have a blank main form. is this in a completely new system?

maybe you could do a dcount("*",me.recordsource) in the main form, and either enable/disable the subform depending on whether the result is 0 or not.
 
hi gemma/David))))

no, it's not completely new but there will always a situation when they just entered a new record on the main form and the 1st nested subform will have no records. i'm just trying to prevent the situation of them adding the 2nd nested subform records before they add the 1st nested subform record.


thank you for the dcount of recordsource, i didn't think of that. will try in a few hours and post back but i'm sure you're right.


since you're already here, wanted to thank you again for the combinations code, the matching tool i built by using that code is used at my job all the time.
 

Users who are viewing this thread

Back
Top Bottom