Disabling controls via code (visual basic 2003) - InfoPath Dev
in

InfoPath Dev

Disabling controls via code (visual basic 2003)

Last post 08-26-2010 03:09 AM by Qazi Anis. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-25-2010 03:24 AM

    Disabling controls via code (visual basic 2003)

    Hello,

     I have created a questionnaire, which works fine and all, but I'd like to make a little bit better.. Now, I have a long list of questions, and each questions have 4 possible answers, which are checkboxes. In the end of the questionnaire, I have a control (radio button), which disables all of the checkboxes, so that the people taking the questionnaire or the people going through the answers, can't modify the answers after it has been submitted to Sharepoint. Now, I could go through all of them tens of checkboxes one by one with conditionnal formatting, but it goes without saying that it's very tiresome and slow.

    Because of this, I'd like to write a piece of code (the form has visual basic 2003 compatible code, since it necessarily has to work with Infopath 2003), which could disable all the checkboxes if a certain control has a certain value.

    For example like this:

     

    if control1 is set to "true"

    then disable each control starting with the name "checkbox1", "checkbox2", "checkbox3" etc

     

    Is this possible to do?

    Thanks in advance,

    Mikko

  • 08-25-2010 07:09 AM In reply to

    Re: Disabling controls via code (visual basic 2003)

    Hi Miggers, I don't think it's possible to modify by code your control. The easiest way is to set some conditionnal formatting.

  • 08-25-2010 07:28 AM In reply to

    Re: Disabling controls via code (visual basic 2003)

    What you're describing isn't possible.

     I would suggest using a form design that uses a locked repeating section instead of a hardcoded layout and questions.  Then you'd only need to set conditional formatting on a few checkboxes.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-25-2010 11:51 PM In reply to

    Re: Disabling controls via code (visual basic 2003)

    Hi,

     Thanks for the answers. I started making this form with Infopath 2007, where I could simple make a view read-only, which worked just perfectly. But as it turned out, I had to make it Infopath 2003 compatible, so the read-only option is out of question now.

    Anyways, is there a way then to make a view or controls read-only for example after the user has pressed a button, radio button or something? We tried this using code, but we only managed to make fields read-only, without any logic. So the form was unusable then.

    The other question is about the sections. I already use sections in my form. They're used to hide/reveal question boxes, because we wanted the form to randomize for example 5 out of 10 questions. But what I don't understand is that what do you mean with locking sections? In my Infopath, the section's conditional formatting has only options to hide the sections, which is out of question.

    -Mikko

  • 08-26-2010 03:09 AM In reply to

    Re: Disabling controls via code (visual basic 2003)

    we can write conditional formatting to make fields read only. just use some conditional like

    if check_visibility is equal to yes

    set field read only

    on the click of the button set the value fo check_visibility field to yes

    Qazi Anis
    Technical Architect
    Bitwise Inc
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.