Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Checkboxes Again (A2K)

    In a report I'm displaying a checkbox with the data name being OwnSVF and the checkbox name being cbS. All I'm trying to do within the report is have the checkbox display only when it is equal to -1. I've tried variations similar to:
    IIf ([OwnSVF] = -1), cbS.Visible = True, cbS.Visible = False
    and was laughed at by Access. Any suggestions or am I barking up an unclimbable tree? Thanks in advance for any help.
    Cheers,
    Andy

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Checkboxes Again (A2K)

    Why did Access laugh at you, what was the error message?
    I don't think your command is correct.
    Are you coding this in VBA?
    HTH
    Pat

  3. #3
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Maidstone, Kent, England
    Posts
    398
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checkboxes Again (A2K)

    Where are you putting your code? I think that it needs to be in the Detail-Format, Something like

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If me![OwnSVF] = -1Then
    cbS.Visible = True
    else
    cbS.Visible = False
    End If
    End Sub

    HTH

    Peter

  4. #4
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checkboxes Again (A2K)

    Bat17 is correct...the code must be in the On Format event of the appropriate report section (Header, Detail, etc.).

  5. #5
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checkboxes Again (A2K)

    As always the friendly Woody loungers come through. I promise to be less cute and more clear in the future when airing out my Access problems. In this particular case, I had the right idea with respect to the code needed, but applied it in the wrong place. Thanks again to all of you folks who jumped in.

    Andy
    Cheers,
    Andy

  6. #6
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Checkboxes Again (A2K)

    Hi Andy,
    Just for future reference, your original error was down to the way you were trying to use IIf. The IIf function returns a value, it doesn't perform an action. You could have used it like this:
    cbS.visible = iif([OwnSVF]=-1,True, False)
    because that way the IIf function is returning either True or False, it's not attempting to assign the value to anything. Otherwise, you have to use the If...Then..Else syntax suggested previously.
    I hope that makes sense.
    Regards,
    Rory

    Microsoft MVP - Excel

  7. #7
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Checkboxes Again (A2K)

    Rory:
    Thanks for taking the time to offer the extra help. I'll use your variation on this code to see how it works for me. One of the real pluses of being in the "Lounge" is learning newer and/or better ways of doing things. Thanks again.

    Andy
    Cheers,
    Andy

Posting Permissions

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