Get the number of the chosen entry in a Dynamic Choise field
Hi,
In a normal Choice field you can have a FX field that dispalys the number of the selected choice like this:
number(ChoiceFieldName), then the FX displays 0 if emty, 1 for choice1, 2 for choice2 etc.
I cant get similar to work for a Dynamic Choice field. It is set up to be Combobox.
number(DynamicChoiceName) just gives me the Id number for the selecte Record, from the table where the Daynamic Choice has its source.
I have tried using chosen, but this dont seem to be valid for a Dynamic Choice. (function is not defined)
Is there a way to do this? My goal is to create a "Next" button and "Previous" button, so I dont have to use the combobox, if i just quicly want to scroll through the list.
7 replies
-
said:
My goal is to create a "Next" button and "Previous" button, so I dont have to use the combobox, if i just quicly want to scroll through the list.Just want to make sure I understand what you want, you want to create a button that you can use to make the next/previous selection of a dynamic field? Can you use radio buttons so you can quickly change your selection?
How many choices show up in the dynamic field?
What is the dynamic value formula for the dynamic choice field?
-
I have a formula to those 2 buttons but you'll need to adapt them to your requirements:
prev button:
let rec := record(Names,number(DynChoice)); let c := index((select Names) order by Name, rec); if c != 0 then DynChoice := item((select Names) order by Name, c - 1) end
next button:
let rec := record(Names,number(DynChoice)); let c := index((select Names) order by Name, rec); let t := cnt((select Names) order by Name) - 1; if t > c then DynChoice := item((select Names) order by Name, c + 1) end
Here is Names the source table of the choice field.
Only thing you have to adapt is the select() to your needs.
Edit: Just saw that is also involved. Sorry for jumping in, maybe you'll find a neater code... (I know you will )
-
Haavard Hjorteland said:
The list can be long, as pr. now close to 100 in some occations, so Radio button take up to much space.Wow that is a long list. FYI, dynamic fields only show you the first 100 records, so if you ever get over that then you will not see all of the records.
If you use a reference field, set to pop up, you can see all related records and also search on data.
For you code, have you looked into using a switch() command? It would look something like:
do as server let grd := text(Gard); let gn := text(GV_F); switch Beboer_Sortering case 1: (select Pers_Bydebok where Stedsnavn.Stedsnavn = grd and Stedsnavn.'Gnr.2021' = gn) order by Beboernr case 2: (select Pers_Bydebok where Stedsnavn.Stedsnavn = grd and Stedsnavn.'Gnr.2021' = gn) order by Person.Fornavn + Person.Farsnavn case 3: (select Pers_Bydebok where Stedsnavn.Stedsnavn = grd and Stedsnavn.'Gnr.2021' = gn) order by Person.Etternavn case 4: (select Pers_Bydebok where Stedsnavn.Stedsnavn = grd and Stedsnavn.'Gnr.2021' = gn) order by year(Fra) default: (select Pers_Bydebok where Stedsnavn.Stedsnavn = grd and Stedsnavn.'Gnr.2021' = gn) order by Beboernr end end
wrote:
Edit: Just saw that is also involved. Sorry for jumping in, maybe you'll find a neater code... (I know you will )
You can jump in anytime. The more the merrier.
-
Haavard Hjorteland said:
symbol expected do, symbol excpected end and end excpected case at line 5.oops, yes just add do to the end of
switch Beboer_Sortering do
Haavard Hjorteland said:
Regarding the 100 records limit in DC, I myself have DC fields that show thousands of records.Well what do you know. It use to have a limit. I just tried it out on a 5700 record table and was able to access the last record. And you can search.
Though I think for myself the reference field is "faster" as you don't have to do a select to fill in the field. But it works so why change it.
Content aside
- Status Answered
- 1 yr agoLast active
- 7Replies
- 140Views
-
3
Following