Results 1 to 7 of 7

Thread: SelectionFormula problem in Crystal

  1. #1

    Thread Starter
    Addicted Member SkyCoder's Avatar
    Join Date
    Oct 2003
    Location
    Moon Crater 25
    Posts
    183

    SelectionFormula problem in Crystal

    Hi there

    I want to pass a parameter from vb6 that whould return like in this example cust 1 and cust 2. How do I do this? Because the selection formula does not seem to work

    CR1.ReportFileName = gsReportPath & "\ActiveCust.rpt"
    CR1.SelectionFormula = "{Customer.Id} in ('1' ,'2')"
    CR1.PrintReport

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Is Customer.Id a string? If I remember correctly the Crystal syntax for In is square brackets. Try

    CR1.SelectionFormula = "{Customer.Id} in ['1' ,'2']"

  3. #3

    Thread Starter
    Addicted Member SkyCoder's Avatar
    Join Date
    Oct 2003
    Location
    Moon Crater 25
    Posts
    183
    how would it be handled for a numeric type?

    CR1.SelectionFormula = "{Customer.Id} in [1 ,2]"
    i have tried this but it doesnt work

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Earlier I should have written

    The Crystal syntax for In with string parameters is square brackets

    CR1.SelectionFormula = "{Customer.Id} in ['1' ,'2']"

    The Crystal syntax for In with numeric parameters is the parentheses

    CR1.SelectionFormula = "{Customer.Id} in (1 ,2)"

    Note - I am going by memory on this one.

  5. #5

    Thread Starter
    Addicted Member SkyCoder's Avatar
    Join Date
    Oct 2003
    Location
    Moon Crater 25
    Posts
    183
    i cant seem to get the numeric one working so it looks like im left with doing it the long way ie:
    CR1.SelectionFormula = "{Cust.Id} = 1 or {Cust.Id} = 2"

  6. #6
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034
    How would you use a VB variable in place of the values 1 or 2?

  7. #7

    Thread Starter
    Addicted Member SkyCoder's Avatar
    Join Date
    Oct 2003
    Location
    Moon Crater 25
    Posts
    183
    Something like this

    Dim str as string
    Dim x as integer

    for x = 1 to lstCust.ListCount -1
    if x = 1 then
    str = "{Cust.Id} =" & lstCust.ItemData(X)
    else
    str = str & "or {Cust.Id} =" & lstCust.ItemData(X)
    end if

    next x

    CR1.SelectionFormula = str

Posting Permissions

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



Click Here to Expand Forum to Full Width