10 Replies Latest reply on Nov 2, 2008 7:14 PM by davidhead

    Less than or equal to 30 days

    jd2775

      Title

      Less than or equal to 30 days

      Post

      That is the script I am trying to run , but when I am creating it it wont allow that.  I am clicking on the "date" field in the table and then the less than or equal to sign, and clicking "add".  It says it is not in the proper date format?  

       

      Basically I want to run a report on all fields in a table in the last 30 days.  I want this to be a function that can be done at any time, to include 30 days from that date.

       

      Now that I am typing this out I am figuring out that I shouldnt include the actual date field from the report in my script setup, as the date could be any date. 

       

      Any ideas? 

       

      Thanks 

        • 1. Re: Less than or equal to 30 days
          davidhead
            

          What you need to do in the script is to construct the search required like this:

           

            Enter Find Mode [ ]

            Set Field [YourTable::yourDateField; <calculated result here>]

            Perform Find [ ]

           

          Notice that neither the Enter Find Mode nor Perform Find has a pause.

           

          The Set Field step has two options - one to specify a target field - this will be the date field you are searching on. The other option is to specify a calculated result. To find the records in the previous 30 days from today, the expression to use would be:

           

          ( Get (CurrentDate ) - 30 ) & "..." &  Get (CurrentDate )

           

          See how that works for you. 

          • 2. Re: Less than or equal to 30 days
            jd2775
              

            Uggghh confusing.  Sorry.  This is all new to me, literally.  I may be in over my head.  What I have is 1 table, with 6-7 fields that will be updated everyday, including a date.  No big deal.  I then followed the manual to add a "Report" to the layout mode, so I could design a script for it.  I called it the "30day report".  Within my main table I have a date field that I have set to autofill (current date).   

             

            I tried your calculations but still got the same message.  I am totally confused. Maybe I am going through the steps incorrectly from the beginning.    

             

            Thanks for the help 

            • 3. Re: Less than or equal to 30 days
              davidhead
                

              First of all you do not have to create a layout to create a script. Go straight to the Scripts menu and choose ScriptMaker.

              So you have a script - 30day report. Double-click it to open the script in ScriptMaker. That is where you need to put the script steps I have indicated.
               
              On a side note to moderators - this forum is VERY frustrating in not being able to post sample files to show people how to do things. We are not getting paid for this and it takes a long time to explain what would be simple to see in a sample. A sample is worth a thousand words. 

               

              • 4. Re: Less than or equal to 30 days
                jd2775
                  

                I agree, thank you David.  I will try your method again

                 

                I appreciate the help! 

                • 5. Re: Less than or equal to 30 days
                  Sorbsbuster
                    

                  Quote: " ...am clicking on the "date" field in the table and then the less than or equal to sign, and clicking "add" "

                   Where do you get the 'add' option from?

                   

                  Have you used Access before?  (Just wondering, in case you think you need to create a Report first, then attach all sorts of other things to that report, like searches and sorts, for instance.  If that is the case, it is always easier if you just say exactly what you want to achieve, rather then describing what you've actually done and try to have it de-bugged)

                   

                  Finding records where the 'Date' is any time in the last 30 days is dead easy, exactly as David Head describes it.

                   

                  Here to help,

                  Alan.

                   

                  (PS: David - I'm new to the whole 'Forum' idea and would not wish to breach protocol or appear rude.  Is it okay for me to chip in on a posting you're answering, or should I butt out and leave you guys to it?)

                  • 6. Re: Less than or equal to 30 days
                    davidhead
                      

                    Sorb

                    No problems at all - butt away ;) 

                    • 7. Re: Less than or equal to 30 days
                      jd2775
                        

                      Thank you guys, I figured it out.  Also, just cut and pasted to get Scripts for 30, 60 and 180 days!  Perfect.

                       

                      Is there a shortcut you can paste on the table itself that you can click on to get these functions? Or do you have to go to the toolbar, Scripts etc etc..everytime?

                       

                      Thanks again! 

                      • 8. Re: Less than or equal to 30 days
                        davidhead
                           You can create buttons on a layout that run each script. When in layout mode, click to select the button tool (it has a button with a hand on it, to the right above the Field tool). On your layout drag to create a button, select Perform Script and specify the script to run, click OK, then type a name for the button.
                        • 9. Re: Less than or equal to 30 days
                          jd2775
                            

                          Thanks Dave, 

                           

                          I figured it out, but is there a way to have these buttons on the main data entry form itself?  I tried that and it cant really search everything because those fields are set. It just flashes the data real fast in the entry boxes, but not as a "report" style. 

                           

                          I added it to my "reports" page as well which was set with specific headers and scripts, and it showed in layout mode, but when I switched it browse or find mode the buttons are gone. 

                          • 10. Re: Less than or equal to 30 days
                            davidhead
                              

                            Hmmm, I don't really understand what you are asking for. If you have the buttons on the main data entry form, the scripts will return the found set. If that layout is being viewed as a form, you can scroll through the records one at a time. If you have a list, you can see a list of the found records.
                            I don't know what you mean by "cant really search everything because those fields are set"? And I am confused by the following sentence too. :(
                            Perhaps you would like to send a clone of your database to me - private message me and I will send you my email address. Otherwise we are really fumbling in the dark to understand where you are at with your file.