Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Help with a Filter

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help with a Filter

    Just a quicky. I cannot seem to get this bit of code to work together. Can someone spot where i have gone wrong?

    Code:
    If alltrim(vDSR) = "" then
       Filter = "type =" +quote(type)+" .and. warranty_expiry >= {"+fromdate+"} .and. warranty_expiry <= {"+todate+"}"
    else
        Filter = "dsr =" +quote(vDSR)+" .and. type =" +quote(Type)+" .and. warranty_expiry >= {"+fromdate+"} .and. warranty_expiry <= {"+todate+"}"
    end if
    * vDSR is a Dropdown (Character Field)
    * Type is a Dropdown (Character Field)
    * fromdate is a Date Field
    * todate is a Date Field

    A user should be able to filter by

    Type, vDSR and Dates
    Type and Dates
    or
    vDSR and Dates

    Thanks

    Denis
    Last edited by den1s; 07-05-2007, 11:02 AM.

    #2
    Re: Help with a Filter

    I'd use the report genie in the dialog to create the filter then use it for your purposes, it gets the syntax right everytime.

    AfterValidate>Insert>Genie>Print Report
    Insanity: doing the same thing over and over again and expecting different results.
    Albert Einstein, (attributed)
    US (German-born) physicist (1879 - 1955)

    Comment


      #3
      Re: Help with a Filter

      Pete,

      That was very very useful. Im surprised i got this far without realising the power of the genie.

      I did what you advised and got the code below. The only problem is i cannot get the dropdown field to also work on their own. e.g. just DSR or just Type or just fromdate - todate.

      Code:
      IF eval_valid("vDSR") = .f. .or. eval_valid("Type") = .f. .or. eval_valid("fromdate") = .f. .or. eval_valid("todate") = .f. Then
      	goto skipreport
      end if 
      dim filter as c 
      dim order as c 
      Filter = "(Dsr = \""+vDSR+"\"  )  .and. (Type = \""+Type+"\"  ) .or. (between(Date_disp_cert,ctod(\""+convert_type(fromdate,"C")+"\"),ctod(\""+convert_type(todate,"C")+"\")) )"
      Order = ""
      Dim filename as c 
      filename = session.session_folder + "tempreport.pdf"
      filename = report.saveas("rptWarranty_Rep@[PathAlias.ADB_Path]\assets.ddd","pdf",filter,order,filename,.f.)
      if file.exists(filename) 
      	currentform.RedirectTarget = session.session_url + "tempreport.pdf?" +  time("hms3")
      end if 	
      skipreport:
      I tried adding .or. between the vDSR and Type but no success. Well yes the dropdown filter worked, but when you wanted to use both vDSR and Type together it gave the wrong results. I almost need an intelligent and/or depending whether the dropdown was used or not.

      I also attempted to use ALL|* in the dropdown selection, but again didnt work.

      What do you think?

      Denis
      Last edited by den1s; 07-06-2007, 01:29 PM.

      Comment


        #4
        Re: Help with a Filter

        Denis,

        You can use a series of if statements and build the filter step by step. For example,

        Code:
         
        if type="All"
        filter=.t.
        else
        filter="Type = \""+Type+"\"" 
        end if
         
        if alltrim(vDSR)=""
        filter=filter
        else
        filter=filter+".and. DSR = \""+vDSR+"\""
        end if
         
        filter=filter+".or. ....
        Pat
        Pat Bremkamp
        MindKicks Consulting

        Comment


          #5
          Re: Help with a Filter

          Pat is right, build them as he shows, works well.
          Peter
          Insanity: doing the same thing over and over again and expecting different results.
          Albert Einstein, (attributed)
          US (German-born) physicist (1879 - 1955)

          Comment


            #6
            Re: Help with a Filter

            Pat,

            Thank you for the example. Have i structured this code in the correct way, so that your code works? Unfortunately, the Type and vDSR do not work together, but do work on their own. I also am not sure how i will construct the between dates for this to work.

            Code:
            IF eval_valid("vDSR") = .f. .or. eval_valid("Type") = .f. .or. eval_valid("fromDate") = .f. .or. eval_valid("toDate") = .f. Then
            	goto skipreport
            end if 
            
            dim filter as c 
            dim order as c 
            
            Filter = "(Dsr = \""+vDSR+"\"  )  .or. (Type = \""+Type+"\"  ) .or. (between(Date_disp_cert,ctod(\""+convert_type(fromdate,"C")+"\"),ctod(\""+convert_type(todate,"C")+"\")) )"
            
            if type="All"
            filter=.t.
            else
            filter="Type = \""+Type+"\"" 
            end if
             
            if vDSR="All"
            filter=.t.
            else
            filter="dsr = \""+vDSR+"\"" 
            end if
            
            if alltrim(Type)=""
            filter=filter
            else
            filter=filter+".and. type = \""+Type+"\""
            end if
            
            if alltrim(vDSR)=""
            filter=filter
            else
            filter=filter+".and. DSR = \""+vDSR+"\""
            end if
            
            
            Order = "Date_disp_cert"
            Dim filename as c 
            filename = session.session_folder + "tempreport.pdf"
            filename = report.saveas("rptWarranty_Rep@[PathAlias.ADB_Path]\assets.ddd","pdf",filter,order,filename,.f.)
            if file.exists(filename) 
            	currentform.RedirectTarget = session.session_url + "tempreport.pdf?" +  time("hms3")
            end if 	
            skipreport:
            Thank you very much. It will be great to get this one closed soon.

            Denis

            Comment


              #7
              Re: Help with a Filter

              Bump!

              Can anyone please help me with this?
              Last edited by den1s; 07-09-2007, 12:47 PM.

              Comment


                #8
                Re: Help with a Filter

                This should sort you out.

                Code:
                 query.Filter =  "Client_id= \""+Client_Code + chr(34) + " .and.  between(ctod(Date_Shipped),ctod(\""+From_Date+"\"),ctod(\""+To_Date+"\"))"
                Insanity: doing the same thing over and over again and expecting different results.
                Albert Einstein, (attributed)
                US (German-born) physicist (1879 - 1955)

                Comment


                  #9
                  Re: Help with a Filter

                  Hi Peter, thanks for the code.

                  I have looked at it, but am not sure how that is going to help me. I have 4 fields in total on the page;

                  DSR
                  Type
                  fromDate
                  toDate

                  They should be able to all work together or independantly of eachother.

                  Do you know how i can incorporate yours and Pats code to achieve this.

                  Massive Brick Wall For Me At The Mo.

                  Any further help is really appreciated.

                  Denis

                  Comment


                    #10
                    Re: Help with a Filter

                    vDSR is a Dropdown (Character Field) is this a multiSelect?
                    Insanity: doing the same thing over and over again and expecting different results.
                    Albert Einstein, (attributed)
                    US (German-born) physicist (1879 - 1955)

                    Comment


                      #11
                      Re: Help with a Filter

                      My four fields on the page are;

                      vDSR = Dropdown (Single select)
                      Type = Dropdown (Single Select)
                      fromDate = Textbox with Calendar icon
                      toDate = Textbox with Calendar icon

                      Denis

                      Comment


                        #12
                        Re: Help with a Filter

                        Code:
                        query.Filter =  "Dsr= \""+vDSR + chr(34) + " .OR. "Type= \""+Type + chr(34) + " .OR.  between(ctod(Date_disp_cert_[B]str[/B]),ctod(\""+fromdate+"\"),ctod(\""+todate+"\"))"
                        Inthe table
                        Date_disp_cert_str is a character field (not a date) This can be a calculated field based on a date and converted to string as a field Rule; e.g. Date_disp_cert_str =dtoc(Date_disp_cert) or just change Date_disp_cert to a "C" Character Field.

                        fromdate and todate a dates converted to string for the search (it's just one of those things that need to be done), but are set as Date (D) variables in the dialog to enable the calander etc. Ensure the settings are dd/mm/yyyy as the default is mm/dd/yyyy and it will trip you up everytime.


                        It's a little hard to really make it work without the table, so if you really get stuck send it to me.

                        Peter
                        Insanity: doing the same thing over and over again and expecting different results.
                        Albert Einstein, (attributed)
                        US (German-born) physicist (1879 - 1955)

                        Comment


                          #13
                          Re: Help with a Filter

                          Peter,

                          Thank you for the extra info. I just cannot seem to put this all together.

                          I have attached this part of the database for you to look at.

                          Really appreciate your support on this one.

                          Thanks again.

                          Denis

                          Comment


                            #14
                            Re: Help with a Filter

                            I have done a new dialog and set up etc. they are in the webprojects. The dialog is called answer.
                            Insanity: doing the same thing over and over again and expecting different results.
                            Albert Einstein, (attributed)
                            US (German-born) physicist (1879 - 1955)

                            Comment


                              #15
                              Re: Help with a Filter

                              Here is the code if something goes wrong. Hope this helps, I know what it feel like to be stuck and under pressure.

                              Peter

                              Code:
                              IF eval_valid("VDsr") = .f. .or. eval_valid("VType") = .f. .or. eval_valid("VFromDate") = .f. .or. eval_valid("VToDate") = .f. Then
                              	goto skipreport
                              end if 
                              dim filter as c 
                              dim order as c 
                              
                              Filter = "(Dsr = \""+VDsr+"\"  )  .or. (Type = \""+VType+"\"  ) .or. (between(Date,ctod(\""+convert_type(VFromDate,"C")+"\"),ctod(\""+convert_type(VToDate,"C")+"\")) )"
                              Order = "Dsr+cdate(Date)+Type"
                              Dim filename as c 
                              
                              
                              if Show_as ="PDF" then
                               filename = session.session_folder + "tempreport.pdf"
                               filename = report.saveas("rptWarranty_Rep@[PathAlias.ADB_Path]\assets.ddd","pdf",filter,order,filename,.f.)
                               if file.exists(filename)  
                              	 currentform.RedirectTarget = session.session_url + "tempreport.pdf?" +  time("hms3")
                               end if 	
                              end if
                              
                              
                              if Show_as ="HTML" then    
                               filename = session.session_folder + "tempreport.html"
                               filename = report.saveas("rptWarranty_Rep@[PathAlias.ADB_Path]\assets.ddd","html",filter,order,filename,.f.)
                               if file.exists(filename) 
                               	currentform.RedirectTarget = session.session_url + "tempreport.html?" +  time("hms3")
                               end if 	
                              end if
                              
                              skipreport:
                              Insanity: doing the same thing over and over again and expecting different results.
                              Albert Einstein, (attributed)
                              US (German-born) physicist (1879 - 1955)

                              Comment

                              Working...
                              X