Results 1 to 8 of 8
  1. #1
    Lounger
    Join Date
    Sep 2001
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Display or Not Display (Access 2000 SR-1a)

    I am trying to set the visible property of a yes/no field on a form based on the status of another yes/no field using code on the forms Open Event.

    The code I'm using is:

    If Me.ReleaseMeetingReq = "Yes" Then
    Me.ReleaseMeetingFin.Visible = True
    Else
    Me.ReleaseMeetingFin.Visible = False
    End If

    I'm guessing my syntax isn't correct, because when R..M..Req is actually Yes, the R..M..Fin control disappears, but at all other times it stays visible. Can anyone point out my error, please?

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

    Re: Display or Not Display (Access 2000 SR-1a)

    I can't check at the moment but I think that what you want is

    Me.ReleaseMeetingFin.Visible = Me.ReleaseMeetingReq


    HTH

    Peter

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Display or Not Display (Access 2000 SR-1a)

    The Form_Open event probably isn't what you want. Try the Current event instead, assuming you aren't using a continuous form. If you are, you'll run into problems anyhow because any setting applies to all records, whether or not they meet the critieria being applied.
    Charlotte

  4. #4
    Lounger
    Join Date
    Sep 2001
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display or Not Display (Access 2000 SR-1a)

    Thanks to both of you for your suggestions, implementing both makes it work, though I'm not sure I understand why. Does the second part of the equation automatically imply that the Visible property referred to should be set only when ReleaseMeetingReq field is "yes" without actually typing those words?
    Secondly, this works but only on those records where the ReleaseMeetingFin field has been changed to Yes and then back to No. I get an "invalid use of null" when I open a clean record. This I understand why it is happening, and I think I could fix it by setting the default value of all the records to No rather than Null, but is there a simple way to handle this in code using the Nz function? I tried a couple of times but get invalid object errors.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Display or Not Display (Access 2000 SR-1a)

    The second part says to set the value of Me.ReleaseMeetingFin.Visible to whatever the value of Me.ReleaseMeetingReq is. If ReleaseMeetingReq is True (not a string value but a boolean) then ReleaseMeetingFin will be set visibile. Otherwise, ReleaseMeetingFin should not be visible. You're running into a problem because you haven't set a default value for ReleaseMeetingReq or you've used Null as a default value. In that case, you need to change it to this:

    Me.ReleaseMeetingFin.Visible = Nz(Me.ReleaseMeetingReq,0)

    It would be simpler to just set the default value of ReleaseMeetingReq to False.
    Charlotte

  6. #6
    Lounger
    Join Date
    Sep 2001
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display or Not Display (Access 2000 SR-1a)

    Perfect Charlotte, the explanation makes sense now, and the code change works. I think I will do both, change the code and set the default value to false, at least for now.
    Thanks again for your help.

  7. #7
    New Lounger
    Join Date
    Jan 2001
    Location
    Maryland, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Display or Not Display (Access 2000 SR-1a)

    Is there any way around this? I'm trying to populate unbound fields on my continuous form based certain data criteria. I've tried coding in various events and the results are not what I want. It's all or nothing...

    Thanks for in advance,
    LisaZ.

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Display or Not Display (Access 2000 SR-1a)

    No. A continuous form only contains one instance of each control, even though it looks like you're seeing one for each control in each record. When you change an unbound control value in a continuous form, that's the value you see in all the records, period.
    Charlotte

Posting Permissions

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