Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    If...Then statement question (Access 2K)

    I was wondering, if I could set up an If...Then statement to check a field which tells me which year the participant attended the retreat and then "hide" the experience field on the report if the the attend date is older than a year.

    I want to do something like this: If John Doe attended the retreat in 2001, then his experience field is set to Not Visible.

    TIA.

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If...Then statement question (Access 2K)

    Just put your code in the Format Event of the report's Detail section.
    If .... your conditions... Then
    txtexperience.visible = False
    Else
    txtexperience.visible = True
    End if
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...Then statement question (Access 2K)

    Actually, it is the condition itself that I'm having problem with. How do I put it in proper syntax? I was thinking,

    If Me!txtLastTimeAttend > DatePart(YYYY) Then
    txtexperience.visible=false
    Else
    txtexperience.visible= True

    Is this correct syntax?

  4. #4
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: If...Then statement question (Access 2K)

    Your criteria would be (assuming LastTimeAttend is a valid date field):

    <pre>If Me!txtLastTimeAttend > Date - 365 Then
    txtexperience.Visible = True
    Else
    txtexperience.Visible = False
    End If </pre>


    In above example, if today is 31 July 2002, if the Attend date is 1 Aug 2001 or later txtExperience will be visible. The "Date" function returns current date. Dates are saved as numbers; 1 = one day.

    HTH

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If...Then statement question (Access 2K)

    Your syntax is wrong regardless of what your intentions. DatePart is wrong, and you are trying to compare a date to part of a date. Your first post said to make the textbox invisible if he last attended in 2001, so you would use:

    If DatePart("yyyy",txtLastDateAttended) = 2001 then
    '... etc.

    Of course, this checks that the last date attended was in 2001. If you want it to be BEFORE 2002, you would use <2002.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  6. #6
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...Then statement question (Access 2K)

    It works, but now I'm left with a gaping hole in middle of my report. Is it possible to somehow force the lines to "shrink" together? Right now, the experience text is set to Grow and Shrink = Yes but if there is lengthy text and it is set to Not Visible, it is still forcing lines of data apart, leaving huge gaps in the middle because the text is "still there".

  7. #7
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If...Then statement question (Access 2K)

    Is your Detail section set to AllowShrink=Yes?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  8. #8
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Seattle, Washington, USA
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: If...Then statement question (Access 2K)

    I have it set to Yes, still see a huge gap between two records. It is because the text field is pushing two records apart, even though it is set to Not Visible.

    Brent

  9. #9
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: If...Then statement question (Access 2K)

    You might try setting the height to 0 and Grow=No if you set it to invisible, and Grow=Yes if visible.

    Or, you could change your controlsource to be an expression, something like:
    IIF( datepart("yyyy",datelastattended=2001, null, experience)
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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