Alpha Video Training
Results 1 to 5 of 5

Thread: Broken layout filter or broken programmer?

  1. #1
    Guest
    Real Name
    Tarek El Mohamad
    Join Date
    Nov 2005
    Posts
    34

    Default Broken layout filter or broken programmer?

    In the course of making numerous small tweaks to my application, I seem to have somehow broken the ability to do filtering in reports. My application is such that I have an AfterUpdateRecords event to generate a report to a file, send it in an e-mail, then delete the file via the following code:

    Code:
    function AfterUpdateRecords as v (Args as P, PageVariables as P)
    with PageVariables
    
    name = "notification@c:\alpha five project\notification.dbf"
    format = "PDF"
    filter = "ID = " + Args.DataSubmitted.R1.ID
    order = ""
    filename = "c:\notification.pdf"
    report.saveas(name,format,filter,order,filename,.F.)
    
    addr = "tarek.elmohamad@hotmail.com"
    subject = "Notification Update"
    body = "Please see attached file."
    email_send(addr,subject,body,filename,"","",.T.,format,"","Default",.F.,.T.)
    
    file.remove("c:\notification.pdf")
    
    end with
    end function
    I could swear that the above code functioned perfectly last week (and even confirmed this by referencing an older backup), but now every time I trigger it, I get e-mailed a report that says "Report does not contain any records". If I change the filter to explicitly pick an existing record by ID (i.e.: filter = "ID = 1"), I get the same results. Only when I change the filter to be filter = "" do I get anything different (I get all the records). Being a numeric field, I also tried converting ID and Args.DataSubmitted.R1.ID using various functions, prior to concatenating it into a final filter expression.

    Thinking it may be some WAS issue, I tried the same by opening the report in Design Mode, going to the Report menu and selecting Select Records. Attempting to use the same filters (even ID = n, where n=some record's ID) would result in a message when I generate the report stating "There are no pages in the layout". I even tried building it using the Expression Builder with no positive results.

    Am I missing something embarassingly obvious?

    Regards,
    Tarek

  2. #2
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,635

    Default

    Tarek,

    You are right, the "Args.DataSubmitted.R1.ID" is type character, so it needs to be converted to numeric. You could do that either with the convert_type(ID,"N") or the val() methods.

    Pat

  3. #3
    Guest
    Real Name
    Tarek El Mohamad
    Join Date
    Nov 2005
    Posts
    34

    Default

    Quote Originally Posted by Pat Bremkamp
    Tarek,

    You are right, the "Args.DataSubmitted.R1.ID" is type character, so it needs to be converted to numeric. You could do that either with the convert_type(ID,"N") or the val() methods.

    Pat
    Pat, I did try this, but to no avail. Strangely enough, as soon as I changed it back to the original code above, it all started working again! I previously tinkered with this for hours with just about every variation I could think of and couldn't get it to work. If Args.DataSubmitted.R1.ID is truly a character type, then I don't know why it's working again now, given that my ID field is numeric.

    Very strange..

    Regards,
    Tarek

  4. #4
    Former Alpha Employee JerryBrightbill's Avatar
    Real Name
    Jerry Brightbill
    Join Date
    Apr 2000
    Posts
    5,173

    Default

    If you to evaluate the filer expression

    filter = "ID = " + Args.DataSubmitted.R1.ID

    with a character value for Args.DataSubmitted.R1.ID, you would return a value of

    "ID = 23"

    or from the interactive window

    ?filter
    = "ID = 23"

    assuming the value "23" exists in Args.DataSubmitted.R1.ID. This result is a valid expression to filter on the numeric value in the id field. However, you may find that the dbf format sometimes has issues with evaluating numbers in filters. A more stable filter expression would be to convert the field value to character

    filter = "alltrim(str(ID,12,0)) = \"" + Args.DataSubmitted.R1.ID+"\""

    which would return

    alltrim(str(ID)) = "23"

    or

    ?filter
    = alltrim(str(ID)) = "23"

    from the interactive window.

  5. #5
    Guest
    Real Name
    Tarek El Mohamad
    Join Date
    Nov 2005
    Posts
    34

    Default

    Jerry, thanks for the tip. I've replaced my filter expression with yours and it's been working great.

    Thanks again,
    Tarek

Similar Threads

  1. A5V1 forum is broken
    By JerryBrightbill in forum Forum Usage
    Replies: 4
    Last Post: 09-23-2005, 06:59 PM
  2. Help Link Broken
    By John Gamble in forum Alpha Five Version 6
    Replies: 2
    Last Post: 02-02-2005, 07:58 AM
  3. email_receive(.f.) is broken
    By burtnco in forum Alpha Five Version 5
    Replies: 6
    Last Post: 08-13-2004, 07:26 AM
  4. Broken Password
    By Fred Daniel in forum Alpha Five Version 5
    Replies: 1
    Last Post: 06-24-2004, 08:41 AM
  5. Broken dbf fix?
    By Jeff Stevens in forum Alpha Five Version 4
    Replies: 0
    Last Post: 02-01-2003, 08:36 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •