Hi,
In DF 19.1 I use a code example posted by Fred back in 2014 (see link below).
HTML Code:
https://support.dataaccess.com/Forums/showthread.php?43346-Dynamic-dbCombForms&highlight=dynamic+validation+table
Purpose is to make the dbComboform dynamic, so that the content of the DescriptionValidationTable is depending on another datafield value.
I need to display both the code and description in the dbComboForm, so the Code_Display_Mode is set accordingly.
The technique proposed by Fred, is to define a Refill_List procedure both in the DescriptionValidationTable object and the dbComboForm object, which will synchronize the content those two at "PostFind" and if user changes the "determining" datafield value.
The Refill_List procedure in the dbComboForm is like this:
Code:
Procedure ReFill_list
String sCod sDesc sTestVal
Integer iRow iRows
Variant[][2] vVT
Get Field_Current_Value of oItems_DD Field Items.POCode to sTestVal // This line is just for debugging
Send Combo_Delete_Data
Get TableData of (PO_Item_VT(Self)) to vVT
Move (SizeOfArray(vVT)) to iRows
For iRow from 0 to (iRows-1)
Move vVT[iRow][0] to sCod
Move vVT[iRow][1] to sDesc
Send Combo_Add_Item (sCod + " - " + sDesc)
Set Combo_Value Item iRow to (sCod + " - " + sDesc)
If (Items.POCode=sCod) Begin
Set Value to (sCod + " - " + sDesc)
Get Field_Current_Value of oItems_DD Field Items.POCode to sTestVal // This line is just for debugging
//Set Field_Current_Value of oItems_DD Field Items.POCode to sCod
Set Field_Changed_State of oItems_DD Field Items.POCode to False
End
Loop
End_Procedure
It works quite well, BUT the: Set value statement of dbComboForm to display the current "Code - Description" also sets the corresponding field_Current_Value of the DD object.
This becomes not only the code but the full string of "Code - Description, and therefore the field data validation fails first time on an attempt to save this record and focus goes to the dbComboForm.
If F2 is then pressed again (even without any user changes in dbcomboform) then the field data validation is ok and the save is done.
I tried to look for a more appropriate way to actually put the "Code - Description value in dbcomboform while still having the field_current_value to be only the "Code"
But no luck, can anybody help?
BR
Carsten