1 2 Previous Next 21 Replies Latest reply on Aug 28, 2012 7:50 AM by Michelle_1

    Working with checkboxes

    Michelle_1

      Title

      Working with checkboxes

      Post

      Hi there again!

      I have a Layout "Search" that looks like such:

      Worker Nr.
      Date1
      Date2

      I have a Script that searches betwen a time range, what the selected Worker sold, after i found what i want i create one New Record in another Table with those reasults. Fine.
      In this layout i have a Poupup window, with each Worker and Checkboxes. Fine works good.

      The next i need a script, that get all workers that i selected and for each one of them perform the search
      Im gonna have then many new Invoices at the same time made and save alot of time so that i can go shoes shopping Kidding! maybe...
      Does anybody knows how i can get it?

      Tx in advance for your help & attention.
      Michelle

        • 1. Re: Working with checkboxes
          philmodjunk

          How did you set up your checkboxes? A Global field with a checkbox group? A set of records with a single value check box on each record?

          The basic process is to set up a List of your worker names (or better yet ID numbers) and then your script can loop through them performing the needed set of tasks for one worker each time the script completes a loop--exiting the loop after the last selected worker is processed.

          IF you have a global field with a check box group, you have such a list already that you can use. If you have some other set up such as a set of records with one worker to each record, then the first step is to use that set of records to create that list in a variable.

          • 2. Re: Working with checkboxes
            Michelle_1

            Well i dont think i set really something up...

            i created a new layout and then added a Checkbox field. then it asked for a Value List. I created a value List then from 2 Fields from the Workers Table.

            Tx

             

            • 3. Re: Working with checkboxes
              philmodjunk

              Then you have a value list. And it can be used in a variety of ways. The simplest (not necessarily the best) way is to define a global text field and format it as a check box set with this value list. The draw back to this method is that check box fields have a fixed size. As you gain/lose workers, this field will not automatically resize to fit. If the number of workers increase, the additional names may not show in the field and there will be no indicator to tell you that they are missing.

              On the other hand, you can use a portal or a small pop up window to display your workers in a global list where you can click names to select multiple workers before performing your script.

              The script is much the same except for the details that manage the list. Working from a global field witha checkbox format as a starting point:

              Set error capture [on]
              Loop
                 Set Variable [$K ;value: $K + 1]
                 Exit Loop if [$K > ValueCount ( YourTable::gCheckBoxField )]
                 Enter Find Mode[]
                 Set Field [YourTable::worker ; GetValue ( YourTable::gCheckBoxField ; $K ) ] ---> gCheckBoxField must have global storage specified
                 #Use set field on other fields to specify any other criteria for your find
                 Perform Find []
                 If [ Get ( FoundCount ) // only do the rest of this task if records were actually found ]
                     Sort Records [restore; no dialog]
                     #Do the rest of your report print script here
                 End
              End Loop

              • 4. Re: Working with checkboxes
                Michelle_1

                OMG that looks so complicated!

                where should i put the "go to Layout" step?

                TX!

                • 5. Re: Working with checkboxes
                  Michelle_1

                  it didnt worked, i made something wrong :(

                  • 6. Re: Working with checkboxes
                    philmodjunk

                    go to layout for what purpose? I've only sketched in the skeleton of what you need as I do not know the details of what needs to be done with each worker.

                    "It didn't work" doesn't give me anyway to respond. HOW didn't it work?

                    • 7. Re: Working with checkboxes
                      Michelle_1

                      Hello!

                      Sorry my mistakes, i am latelly in such a hurry with work...

                       

                      I actually have a layout where i can type the Worker nr. and the dates i want to have for my report.

                      in this layout i have a button with the following Script:

                      Go to layout "Invoice"

                      Enter Find Mode

                      Set Field "Date"

                      Set Field "worker nr"

                      Perform Find

                      Sort Records

                      Enter Browse Mode

                       

                      This way i just can get 1 worker at a time.

                      So i created a script that opens a new window.

                      In this window i have a Layout with the checkboxes with all workers.

                      This is a Global Text Field from my table "Workers"

                       

                      Now i dont really know where i add the scripts steps you described, so that i would then select the checkboxes with the workers i want, click a button in this new window  and it would then run our script and generate all the Invoices for my workers. ( then i really dont need the go to layout step)

                      It could in the end go to other layout where i see a list of all the Invoices. This List i already have. The script step i can also make :) i just dont know yet where to put the new script steps you described. I am working on it right now.:)

                      It must somehow after selecting all Workers and dates; go to Reports Layout; ask a new Record for each found worker and save there the results

                       

                      Thank you Very much for your help & attention

                      Michelle

                       

                      • 8. Re: Working with checkboxes
                        Michelle_1

                        Maybe i forgot to mention that i am really very very new user of FM. and i am also not a real developer, i just work on a solution for the company i work.

                        • 9. Re: Working with checkboxes
                          Michelle_1

                          I made some pics of my DB so maybe you can see where is my mistake :)

                          Relationships

                           

                          Script

                           

                          Tx Tx

                          • 10. Re: Working with checkboxes
                            philmodjunk

                            One question first:

                            If you select "Jim" and "Mary" in your check boxes,

                             Do you want to see a single list of found records that combines those for "Jim" and "Mary", or do you want to see one report for "Jim" and one report for "Mary"?

                            • 11. Re: Working with checkboxes
                              Michelle_1

                              Hello Phil,

                              i want to see/generate one report for each worker.

                               

                              Tx ^^

                              • 12. Re: Working with checkboxes
                                philmodjunk

                                And what will you do with those reports? print them? Save them as PDFs? Or do you want the script to pause on the first worker's report and then pull up the next worker's report when you click the continuer button?

                                Assuming that you pause with each report...

                                Set error capture [on]
                                Loop
                                   Set Variable [$K ;value: $K + 1]
                                   Exit Loop if [$K > ValueCount ( YourTable::gCheckBoxField )]
                                   Enter Find Mode[]
                                   Set Field [Invoice::worker nr; GetValue ( Invoice::gCheckBoxField ; $K ) ] ---> gCheckBoxField must have global storage specified
                                   Set Field [Invoice::date ; Invoice::gDate]
                                   Perform Find []
                                   If [ Get ( FoundCount ) // only do the rest of this task if records were actually found ]
                                       Sort Records [restore; no dialog]
                                       Pause/Resume Script [Indefinitely]
                                   Else
                                       Show Custom Dialog ["No records found for Worker #" & GetValue ( Invoice::gCheckBoxField ; $K ) & " and date: " & Invoices::gDate ]
                                   End If
                                End Loop

                                • 13. Re: Working with checkboxes
                                  Michelle_1

                                  I need to print them, therefore i was planning on using the knowledge i got from you about Checkboxes and in another layout with a reports list that i can filter per Date and/or worker use checkboxes to print the desired workers reports. I plan on learning and making that bymyself, so i can get abit proud and really learn what you show me here ^^

                                   

                                  Txx

                                  • 14. Re: Working with checkboxes
                                    philmodjunk

                                    Set error capture [on]
                                    Loop
                                       Set Variable [$K ;value: $K + 1]
                                       Exit Loop if [$K > ValueCount ( YourTable::gCheckBoxField )]
                                       Enter Find Mode[]
                                       Set Field [Invoice::worker nr; GetValue ( Invoice::gCheckBoxField ; $K ) ] ---> gCheckBoxField must have global storage specified
                                       Set Field [Invoice::date ; Invoice::gDate]
                                       Perform Find []
                                       If [ Get ( FoundCount ) // only do the rest of this task if records were actually found ]
                                           Sort Records [restore; no dialog]
                                           Print
                                       Else
                                           Show Custom Dialog ["No records found for Worker #" & GetValue ( Invoice::gCheckBoxField ; $K ) & " and date: " & Invoices::gDate ]
                                       End If
                                    End Loop

                                    1 2 Previous Next