Results 1 to 4 of 4

Thread: visibility

  1. #1
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have the following problem: My code for making visible controls on the continous form is not working.How could i make it work ?It is the following:
    If Me.supplierid = 1 Then
    Me.RaufGrade.Visible = True
    Me.RaufCode.Visible = True
    ElseIf Me.supplierid = 2 Then
    Me.AralGrade.Visible = True
    Me.AralCode.Visible = True
    End If
    I tried to use it in OnOpen event as well as in the OnCurrent event but without success

  2. #2
    New Lounger
    Join Date
    Jan 2010
    Location
    Reading U.K.
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi
    just tested a bit of code in the OnCurrent event that seems to work.
    Only difference to yours is that I added a few lines to turn controls invisible when going to a different supplier record and set both controls to visible=NO in the properties.

    e.g.
    If Me.supplierid = 1 Then
    Me.RaufGrade.Visible = True
    Me.RaufCode.Visible = True
    Me.AralGrade.Visible = false
    Me.AralCode.Visible = false
    ElseIf Me.supplierid = 2 Then
    Me.AralGrade.Visible = True
    Me.AralCode.Visible = True
    Me.RaufGrade.Visible = false
    Me.RaufCode.Visible = false
    End If

    hope that helps

  3. #3
    Lounger
    Join Date
    Apr 2010
    Location
    Sofia
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, it helped me a lot! Your suggestion was excellent and i thank you very much! I solved one big problem for me

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    There is a much more compact way to write out expressions like those above

    Code:
    Me.RaufGrade.Visible = (Me.supplierid = 1)
     Me.RaufCode.Visible =(Me.supplierid = 1)
     Me.AralGrade.Visible = (Me.supplierid = 2)
     Me.AralCode.Visible =(Me.supplierid = 2)
    Initially there is some loss of readability, but once you get used to them, these expressions make a lot of sense.
    They rely on the fact that the bit in the brackets is either true or false, so the visibility is set to either true or false

    Added later: I have just noticed that this relates to a continuous form. In a continuous form there is really only one copy of a control, so if something is not visible, it is not visible in all records. Is that a problem for you?
    The alternative approach which does work with continuous forms is to use conditional formatting, but you can't change visibility that way.
    Regards
    John



Posting Permissions

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