MsgBox displays twice? - InfoPath Dev
in

InfoPath Dev

MsgBox displays twice?

Last post 08-21-2007 02:36 AM by Shiva. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 07-06-2007 04:25 PM

    MsgBox displays twice?

    Hi:

    I have a little custom code (vbscript) for an OnValidate event. It looks like this:

    Sub msoxd__IssueReportingDev_DetailedDescription_attr_OnValidate(eventObj)

         Dim detDesc

         detDesc = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:IssueReportingDev/@DetailedDescription").text

         if len(detDesc)>=5000 then
         dim msg
         msg = MsgBox("This field cannot contain more than 5,000 characters. You currently have " & formatnumber(len(detDesc),0) & " characters. Please revise your entry.",16,"Detailed Description is too long")
         end if

    End Sub

    When I preview the form (or fill out the published version) if I put more than 5,000 characters in the field, my message box pops up nicely. I can click OK and go back into my field and revise my entry. However, if still have more than 5,000 characters and tab or click out of the field, my message box pops up (expected behavior), I click OK, and it pops up a second time. I have to click OK again before it goes away and lets me revise my field. Is it my if statement? Or something else? Oh, I am designing in IP 2007 but the people using this will be using IP 2003. Thank you for any help/ideas!

    Hilary

  • 08-21-2007 02:36 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Hi,

    These events are fires two times. One is eventObj operation is equal to ‘Delete’ and ‘Insert’. For these type of twice calling method eliminates we have to add one condition as shown below:

    if(eventObj.Operation != “Insert”)

    {

    return;

    }

    Hope this help you

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