2 Replies Latest reply on Jul 17, 2013 10:42 AM by Popof

    Create N similar records from check boxes?

    Popof

      Title

      Create N similar records from check boxes?

      Post

           Hello All, 

            

           First of all, Hi, my name is Romain, and I'm quite new to FMPro. (FM actually).

            

           I've recently developped a little database for one of my clients which works just fine. it does what I want it to do, and that's great.

            

           HOWEVER, I'm stuck with one simple issue, and can't seem to find any "simple" solutions out there, whereas my feeling is that there might be one. Maybe I'm not looking with the right words, English is not my mother tongue so please forgive me if this is something huge that I've missed but I really can't find anything.

            

           Basically I'm typing travel expenses for my client's employees (keeping it simple)

           So each month I'll be getting expense sheets (paper) from this client's employees and I'll type them into my database.

           Basically it goes like this:

           Employee Number# (I type it)

           Employee Name (autofill from another table) 

           Employee data (email, adress etc, autofill from the other table)

           Month of expense (I type it from a dropdown menu)

           Value (I type it)

           It so gives a record that looks like this:

           Employee # // Name // Employee email and data // MONTH // Value

           That works just fine. i'm happy so far.

            

           But I frequently have multiple consecutive expense sheets for consecutive months, for example, same employee, same number, same everything, same expense (say a Subway monthly fare, always the same) and for the months of: JAN, FEB, MAR, APR.

            

           Right now I'm stuck doing January and then manually duplicating and editing the month to make 4 records. (I NEED the output file to be 4 records and not 1 record with 4 columns unfortunately)

            

           So I was hoping to implement something like 12 optionnal check boxes for the months, and If i check say JAN, MAR and JUN, that will automatically create 3 different records such as:

            

           Rec 1: Employee # // Doe // John // john.doe@server.com // JAN // 20$

           Rec 2: Employee # // Doe // John // john.doe@server.com // MAR // 20$

           Rec 3: Employee # // Doe // John // john.doe@server.com // JUN // 20$

            

           Is that feasible easily by any chance?

            

           Please forgive the probably newbie-question, but I'm really not a computer guy initially so i'm trying hard here ;)

            

           Thanks tp all.

           Romain

        • 1. Re: Create N similar records from check boxes?
          philmodjunk

               Your English is Excellent.

               And keeping the entries in separate records is the better way to go so your basic structure is what you should have here.

               With a field formatted with checkboxes, the values you select are entered into the field as text separated by returns. A scritp can easily loop through that list and create the needed records. You might consider entering/selecting your data in fields with global storage and then clicking a "save" button that actually creates the needed record or records from the data in the global fields. That way, you do exactly the same thing whether you specify the expense for a single date or set it up as one that repeats over multiple months.

               Here's a script that does not use global fields for this, but it can easily be adapted for such if you want to:

               Set Variable [ $MonthList ;  Value: YourTable::MonthsCheckBoxes ]
               Loop
                 Set Variable [ $K ; Value: $K + 1 ]
                 Set Field [ YourTable::MonthsCheckBoxes ; GetValue ( $MonthList; $K ) ]
                 Exit Loop IF [ $K > ValueCount ( $MonthList ) ]
                 Duplicate Record
               End Loop

               Note, if you want, you can have a separate fields for the month and the checkbox list of months. If you do, the set field step would be changed to set a value to the month field instead of the MonthsCheckBoxes field.

          • 2. Re: Create N similar records from check boxes?
            Popof

                 Wow!

                  

                 Thank you so much for the quick answer!

                  

                 So I guess I'll have to look into global storage! Thank you so much for the script, as I said, still a beginner here, but I'll study it and see how I can use it!

                 Kind regards,