Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2013
    Posts
    1

    Unanswered: Field visibility based on checkbox

    Hello
    I really hope someone can help me. I am trying to create a form and that will only display certain fields when a checkbox is checked. For example if a case is assigned to one reviewer but has to be reassigned, I want to be able to check the reassignment checkbox and have the date field appear but only if the case is reassigned. I hope I am making sense. Any help would be greatly appreciated!!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    the actual code to handle this is pretty straightforward, however its best to wrap it into a function so you can set the visibility from several places.

    the code:-
    Code:
    public function ShowReviewDate() as boolean
    ShowReviewDate = true ' set up our defualt return state
    if mycheckbox.checked = true then
      ShowReviewDate=true
    else
      ShowReviewDate=false
    endif
    end function
    ..although to be honest you could re phrase that as
    Code:
    public function ShowReviewDate() as boolean
      ShowReviewDate = mycheckbox.checked
    end function
    then you need to use that function to set the visibility as required.
    to do that you need to call the fucntion when the checkbox changes state (the on cliock event) AND when a new row is displayed (the on current event). that call is
    reviewdatecontrol.visibile = ShowReviewDate, although to be perfectly hones you coudl just use:-
    reviewdatecontrol.visibile = mycheckbox.checked
    the reason for pushing the code to a fnction (which is actually needless here) is that its to separate the data from its presentation, do the test in one place, but use the results in several.
    whe writing code these days you should be trying to unbind business rules from the user interface (so you can use common functions accross the same application, or applications [if it helps think of it as normalisation of code ]), so somtimes you write functions that call functions. ferinstance in this case you might have a common function that handles the actual setting of some controls in the UI calling another function. if you place the code that sets UI values in the data function then you cannot reuse that code elsewhere.

    Say you wanted to hide several controls on your form, pushing this into a function allows you to set all values art the same time

    ..this assumes that you are using a single row form design not continuous forms


    ..incidentally I think you'd be better setting the controls locked property NOT the visitbile property
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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