Enabling A Control (A Button) - InfoPath 2007 - InfoPath Dev
in

InfoPath Dev

Enabling A Control (A Button) - InfoPath 2007

Last post 06-11-2013 11:27 AM by Moe1950. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 06-06-2013 05:15 AM

    Enabling A Control (A Button) - InfoPath 2007

    I have a "Save" button on my form that the user wants enabled only if the report month equals the current month.

    I have a textbox which stores the month number of the report month and another textbox which grabs the current month number from the current date.    If they do not equal, the button is disabled.   This works just fine.

    Now my customer would like me to build in a feature where the button could be reenabled if a password was entered.    So, I put another textbox on the form and I need to it to enable the button is specific text is typed into the textbox.     But, the conditional formatting options only allow me to Hide the button or Disable It.    If it is disabled already, how do I enable it based on a textbox equaling a specific string of text?

     

  • 06-06-2013 05:29 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    You conditional formatting just gets a new condition. Right now that condition is probably something like

    CurrentMonthNumber is not equal to ReportMonth, Disable

    You'll need something like

    CurrentMonthNumber is not equal to ReportMonth AND

    passwordEnteres is not equal to ValidPassword

    then Disable

    Good luck!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 06-07-2013 04:46 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    Actually I have discovered a more fundamental problem.   What I thought was working is not.

    I originally said that I have a textbox which stores the month number of the report month and another textbox which grabs the current month number from the current date.    If they do not equal, the button is disabled.   This works just fine.    That doesn't work just fine.  In fact, it doesn't work at all.

     Even when the report month textbox equals the current month textbox, the button remains disabled.    The conditional formatting of the button is:    if txtMonthNum does not equal txtReportMonth then disable this control - in June the report month and the current month would both be 6 and 6 is in both textboxs so they do equal but the button remains disabled.    What am I missing?

  • 06-07-2013 05:43 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

     Are you sure both fields contain just "6"? If it's "06" or " 6" (space six) or "6 " (six space) then the comparison might fail.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 06-07-2013 05:47 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    Both have just a 6 in them, no 06 entries.

    There are spaces however....I don't know how many.      Both textboxs are left justfied.     Can I use a Trim or Substring in conditional formatting?

  • 06-10-2013 04:33 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    Is there a better way of doing what I need to do than trying to compare the contents of two textboxes?

  • 06-10-2013 05:49 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    The values for the month are calculated via rules in the form, is that correct? What I mean is, the user is not typing in the month number. If that's the case, then the rules just need to be fixed to exclude any extra spaces. Have your rules be consistent and produce always a two digit number, i.e., 01, 02... 11, 12 for the month. Doing so will ensure the comparison will work. As for the extra spaces, I don't know where those would be coming from in the rules. You could try translate(date," ","").

    Good luck.

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 06-10-2013 06:08 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    There are two textboxes.      On the form (in addition to everything else) is a drop down list that has tweleve entries consisting of January 2013 through December 2013.    The form is saved once for each month in the year represented by the entry in the dropdown list.   In addition to changing the dropdown list to correspond to a particular month, I also type, manually, the month number into one of the textboxes as 1, 2, 3, etc 10,11, 12)  The links to each form is presented on another Infopath form as a Menu.   

    When each form is opened, a second textbox is populated via the following formula:   substring(today(), 6, 2)

    This puts the current month number in the second textbox.     I now compare the two textboxes and if the do not equal each other I disable the Save button.     However, even when they do equal, the Save button remains disabled.     For January through September the month number from the substring(today(), 6, 2) formula is saved as a single digit, but, the month number in the other textbox is also a single digit.

    Since that isn't working I'm now trying to figure out how to programmatically get the name of the month from the current date.   My thought is that maybe June in one box would equal June in the other.    I haven't tried it yet, but 6 and 6 are not equalling.    I guess I could give the translate thing a shot.   Thanks. 

  • 06-10-2013 11:52 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    Sorry, I don't know what else to tell you. I have fired up a quick, sample form. In one textbox (string) I used your same formula (I get 06). In the other textbox I just type in the month number (06).

    It works fine. The button is disabled and enabled as I expect. That is, the comparison works correctly.

     

    Moe1950:
    For January through September the month number from the substring(today(), 6, 2) formula is saved as a single digit, but, the month number in the other textbox is also a single digit.

    When I use your formula in my test form, the formula yields 06, not 6, when the field is data type string.

    If I change my form such that the field's data type is whole number (to avoid the leading 0) then you would need to change the result of the formula back to a number. Remember, substring is a string formula, so it returns a string. You could need to do number(substring(today(), 6, 2)) to convert it back to a number. When I do that I get 6 back from the formula, and I can type in a 6 and the formatting works as expected again.

    So, to summarize, in my testing, as long as I keep my data types consistent, the comparison works as expected. It sounds like you've already played around with the form and the various data types. It's unfortunate that it's not working. Moving into a code solution for this seems too complex. Good luck!

    Ernesto Machado
    Qdabra® Software/ InfoPathDev.com
    The InfoPath Experts – Streamline data gathering to turn process into knowledge.™


  • 06-11-2013 11:27 AM In reply to

    Re: Enabling A Control (A Button) - InfoPath 2007

    It looks like I was doing two things wrong.

    1.  I had both textboxes formatting as Whole Number integers.     I didn't realize I could do math expressions like greater than or less than on strings.

    2.  I was entering the report month as a single digit.

    When I changed the textbox format to string and entered the report month as two digits (i.e., 01, 02, 03 etc) the comparsion worked.

    Thank you for your time and patience!   It is much appreciated.

Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.