Concat all the occurences of one field in a related table
Concat all the occurences of one field in a related table
Hi there,
here's the problem. I have the form "Conductors" that is related to the form "Offer_row". A "Offer_row" record can have one or more records related in the "Conductors" table. Any record in "Conductors" has a field called "Color". I have to show, in a single field of the form "Offer_row" all the colors of the conductors. I can not nest the related form "Conductors" in the table "Offer_row" for visual reason: there is little room less and adding that would make a mess. Is there a way - in a derivation - to concatenate the field "Color" in all the related records and put everything in a single field?
Regards.
Re:Concat all the occurences of one field in a related table
Yes.
You don't explain very well if you are wanting to show this in the subform, or if Offer_Row is a Main form record.
It is easier if it is a Main Form as you will be able to insert the result of the EXECDQL directly in the field.
If it is a Main Form record simply create a Label with the DQL that will do the job, and then execute it from a virtual field that will also hide the label with the script and itself.
Vritual field (Manip):
SetState("Manip",0)+SetState("MyDQLLabel",0)+LabelExecDQL("MyDQLLabel",FieldInRelationship)
Label named: MyDQLLabel.
define "retval" text .
define "myConductorColors" text 255 .
for Coundcutors with ID=data-entry field1 ;
list records;
ColorOrderWhateverThatIs in order . -- This is just for sorting.
MyConductorColors := concat(MyConductorCOlors,Color) .
end
retval := SetValue("MyConcatinatedColorsInOffer_ROw",MyConductorsColors) .
If you are going to do the same for each row in a SubForm you will have to use the # denominator on ObjectNames and GetCurrent(RowNumber)
Vritual field (RowManip):
SetState("MyDQLLabel",0)+LabelExecDQL("MyDQLLabel",FieldInRelationship,GetCurrent("RowNumber"))
Label named: MyDQLLabel.
define "retval" text .
retval := SetState(Concat("RowManip#",data-entry field2) .
define "myConductorColors" text 255 .
for Coundcutors with ID=data-entry field1 ;
list records;
ColorOrderWhateverThatIs in order . -- This is just for sorting.
MyConductorColors := concat(MyConductorCOlors,Color) .
end
retval := SetValue(concat(MyConcatinatedColorsInOffer_ROw#",data-entry field2),MyConductorsColors)
Make sure all object names in Subform are unique for subform as the # counts objects names from top of object tree and is completely free of data-model i.e. GUI object oriented ONLY.
Every time we reply to one of your posts we get this error message.
Could you please change to a different email address or fix the problem?
This is an automatically generated Delivery Status Notification.
Delivery to the following recipients failed permanently:
Reason: This is the mail system at host smtp-27.iol.local.I am sorry to have to inform you that your message could not be delivered to debian.potato@libero.it. The message is attached below.The remote mail system said: 550 RCPT TO:<debian.potato@libero.it> Mailbox disk quota exceeded
Re:Re:Concat all the occurences of one field in a related table
Well, it worked, but messed up other things. So I went for a button that opens a related form. The thing with the email is now fixed.
Re:Re:Re:Concat all the occurences of one field in a related table
This shouldn't mess up anything except....
The execdql is part of the context of the form and we have showed a couple of times how you can change the constraint of a relationship (selection) via executing an Execdql.
As much as this is a "feature" it would of course also be a problem if you change the relationship that for instance a Subform is based on.
It is "crazy" that you in DataEase as default create a relationship with the same name as a table as you for ever after that will start with the constraint of that relationship when you build further relationship.
As a rule of thumb... ALWAYS name a relationship, never ever use the default except when the relationship has no field constraint i.e. when you only define it to access another table without constraint.