I have simplified this quite a bit but I have a database structure where I have an employee table (GTEMPM) which has a payroll group code that relates up to a parent payroll group code (GTPRG). For reasons I won't go into for simplicity I cannot relate the actual employee payroll group code field to the parent group code field so I have implemented a unqiue id field in the employee table for the payroll group that relates to a unique id in the payroll group parent. I use Peter Crooks optional relationship package to make this relationship optional.
So bascially I have:
GTEMPM.PRG_UNIQUE ---------> GTPRG.PRG_UNIQUE (optional relationship)
GTPRG.PAYROLL_GROUP (15 char)
Indexes for GTPRG are:
The unique id however is meaningless to the user so I cannot use that on the view so I put the GTPRG.PAYROLL_GROUP on the view (as a dbForm) so the user can search (F7/F8 and lookups) by this. So on my view I have (again very simplified):
This seems to work ok and saves the correct unique id from the parent GTPRG to GTEMPM. The problem I get is if I clear this dbForm (oGTPRG_PAYROLL_GROUP) and press save I get a "Please enter a valid record id" error even though it is an optional relationship. I do realise this is probably because it is talking directly to the oGTPRG_DD rather than via oGTEMPM_DD but I'm not sure how to handle this situation. I did try using onChange in the dbForm checking if the value was blank and then Send Clear of oGTPRG_DD but this didn't work so thought someone may have done something similar and have a few ideas or hooks/code.
Object oGTPRG_DD is a cGtprgANR_DataDictionary
Object oGTEMPM_DD is a cGtempmANR_DataDictionary
Set DDO_Server to oGTPRG_DD
Object oGTEMPM_EMPLOYEE_CODE is a dbForm
Object oGTPRG_PAYROLL_GROUP is a dbForm