Results 1 to 9 of 9
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    IF, AND in VB (2003)

    How does IF, AND work in VB. What I'm trying to achieve is, on a report I have 3 images, A, B, C. On the result of a paramater (Name) and the first letter of a stock code, I want A, and B to be visible. With the same result of the parameter, but a different letter for the stock code, I want A and C to be visible. Hope this makes sense.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IF, AND in VB (2003)

    It's not clear what you mean by "On the result of a paramater (Name)". Which result?

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: IF, AND in VB (2003)

    When the report is run, the user is asked for his/her name. Image A is visible depending on the name, along with B, or C, depending on the first letter of the stock code.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IF, AND in VB (2003)

    Rob,

    If you want us to help you, you'll have to provide clear and sufficient information. "Image A is visible depending on the name" is very vague - how does it depend on the name?

  5. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: IF, AND in VB (2003)

    If the name is Rob, and the Stock Code begins with F, image A and B are visible. If the name is Rob, and the Stock Code doesn't begin with F, image A and C are visble.

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IF, AND in VB (2003)

    And if the name is not Rob?

  7. #7
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: IF, AND in VB (2003)

    Nothing appears

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: IF, AND in VB (2003)

    You could adapt the following code:

    If <!t>[Name]<!/t> = "Rob" Then
    <!t>[A]<!/t>.Visible = True
    If Left(<!t>[StockCode]<!/t>, 1) = "P" Then
    <!t>[B]<!/t>.Visible = True
    <!t>[C]<!/t>.Visible = False
    Else
    <!t>[B]<!/t>.Visible = False
    <!t>[C]<!/t>.Visible = True
    End If
    Else
    <!t>[A]<!/t>.Visible = False
    <!t>[B]<!/t>.Visible = False
    <!t>[C]<!/t>.Visible = False
    End If

    Alternatively, hide all three images at the beginning, and depending on the conditions make some of them visible:

    <!t>[A]<!/t>.Visible = False
    <!t>[B]<!/t>.Visible = False
    <!t>[C]<!/t>.Visible = False
    If <!t>[Name]<!/t> = "Rob" Then
    <!t>[A]<!/t>.Visible = True
    If Left(<!t>[StockCode]<!/t>, 1) = "P" Then
    <!t>[B]<!/t>.Visible = True
    Else
    <!t>[C]<!/t>.Visible = True
    End If
    End If

  9. #9
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: IF, AND in VB (2003)

    Thanks Hans, first option worked fine. Thanks again.

Posting Permissions

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