8 Replies Latest reply on Jun 29, 2012 2:14 PM by TuxfordC

    Find Using Variables

    TuxfordC

      Title

      Find Using Variables

      Post

      I have to search between Dates which have been pre-defined as Global fields. I understood that could be achieved by using declared

      Variables in place of the acutal dates.  The Find function is rejecting these ($....),  and insisting on formatted Dates in the formula.

      Thanks

      TuxfordC

        • 1. Re: Find Using Variables
          Sorbsbuster

          Are you doing this Find manually?  Or by script?  I assume by script.

          Do not specify the Find in the Perform Find step.  Try this script:

          Set Variable [$StartDate ; Get ( CurrentDate ) - 30 ]
          Set Variable [$EndDate ; Get ( CurrentDate ) ]
          Enter Find Mode (uncheck the pause)
          Set Field [YourDateField ; $StartDate & "..." & $EndDate ]
          Perform Find

          You should see that it finds all records for the last 30 days.

          • 2. Re: Find Using Variables
            philmodjunk

            If your dates that spell out the date range you want to use in a search have been entered into global fields, you don't have to use variables--though it does work. You can drop the first two lines of sorbsbuster's script and modify the expression in the set field step to use the global fields instead of the variables.

            • 3. Re: Find Using Variables
              TuxfordC

              Thanks for the replies. Yes it is a script in a programme that will be used by a person not really IT literate so

              it has to work on a button push. The dates in question are the beginning and end of financial periods that have been preset

              in a preferences table.  I wondered if the fact that the end date has be an 'equal to or less than' was confusing

              the issue. Will report results later today.

              TuxfordC

              • 4. Re: Find Using Variables

                Try wrapping your global date field: Getastext(globaldatefield) & "...." & getastext(globaldatefield2)

                In the 'OLD DAYS' we had to use insert text or some silly thing...

                there is also the chance of a choke searchiing for the oldest date...newest date but I doubt this.

                • 5. Re: Find Using Variables
                  philmodjunk

                  Getastext is not necessary for this expression. It does no harm, but isn't the cause of your trouble here.

                  You can always post the actual script you have set up so others can look it over for problems.

                  To post a script to the forum:

                  1. You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                  2. You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
                  3. If You have FileMaker advanced, you can generate a database design report and copy the script as text from there.
                  4. If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format. (Use the HTML option on the database tab panel and paste the text into the forum's HTML editor.)
                  • 6. Re: Find Using Variables
                    TuxfordC

                    Thanks you al for the answers and suggested changes. I must apologise for wasting your time, the problem was earlier in the

                    script where I had added an extra field as an intermediiary as a  possible work-around the Global field issue.  I am still somewhat confused about this.

                    The Filemaker Hep tells me that Global field may not be used in Find, yet Phil says they can be used.  Directly or indirectly by using 'Enter Find Mode'

                    instead of a direct Find instruction?

                    Apologies,

                    TuxfordC.

                    • 7. Re: Find Using Variables
                      Sorbsbuster

                      The Help and Phil are both correct.  You can use a global field as a source of a find criterion, as you have here.  You cannot use a global field as the subject of a find, as by definition all records will have that value, so there is nothing to 'find' one record from another.

                      • 8. Re: Find Using Variables
                        TuxfordC

                         Yes, I fully understand that thanks, guess that I misread the Help. I think we can regard this topic as closed now.

                        Thank'ee

                        TuxfordC