Problem in OnAfterChange code - InfoPath Dev
in

InfoPath Dev

Problem in OnAfterChange code

Last post 06-15-2006 12:32 AM by liorlankri. 11 replies.
Page 1 of 1 (12 items)
Sort Posts: Previous Next
  • 06-12-2006 04:25 AM

    Problem in OnAfterChange code

    I have a OnAfterChange event for text field in my form.

    In this event I ask for sepecific condition (if....)
    I want that in case that the "IF" is FALSE so that value of the field will be empty.
    how to do it?
  • 06-12-2006 06:19 AM In reply to

    Re: Problem in OnAfterChange code

    Hi,

    write this code under OnAfterChange event.

    if(condition == false)
    {
    IXMLDOMNode textNode = thisXDocument.DOM.selectSingleNode(Xpath);
    textNode.text = " ";
    }

    this will work for you,

    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 06-13-2006 12:26 AM In reply to

    Re: Problem in OnAfterChange code

    I try this but somthing strang happen.if I enter correct input (conditin=true) and after i enter not correct input (conditin=false) so the field get the blank value (""). BUT!!! if I enter not correct and after again not correct so the value not get change!!!

    what is the problem??
  • 06-13-2006 01:23 AM In reply to

    Re: Problem in OnAfterChange code

    Hi,

    Iam not getting what you are saying,
    Please provide your code, what you have written in OnAfterChange Event.

    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 06-13-2006 10:03 PM In reply to

    Re: Problem in OnAfterChange code

    This is my code:

    Sub msoxd_my_IdNumber_OnAfterChange(eventObj)

    if eventObj.IsUndoRedo then
    exit Sub
    End if

    if eventObj.Operation = "Delete" then
    exit Sub
    End if

    Dim nodeValue
    nodeValue=eventObj.NewValue

    if Len(nodeValue)>0 then

    if IsIdInputOK(nodeValue)=false then
    XDocument.DOM.selectSingleNode("/my:myFields/my:A/my:IdNumber").text=""
    end if
    end if
    End Sub

    I will explain again:
    I enter input that make IsIdInputOK(nodeValue)=TRUE and after I enter Input that make IsIdInputOK(nodeValue)=FALSE so it's work and i get the value "" in the text field. But if I enter input that make IsIdInputOK(nodeValue)=FALSE and after I enter Input that make IsIdInputOK(nodeValue)=FALSE so it's not work and the wrong value stay on the text field and not change to ""
  • 06-14-2006 12:08 AM In reply to

    Re: Problem in OnAfterChange code

    Hi,

    I think, You have written function for returning true or false based on nodeValue, may be something wrong in it.

    I tried below code, it is working fine for me,

    Sub msoxd_my_field1_OnAfterChange(eventObj)

    If eventObj.IsUndoRedo Then

    Exit Sub
    End If

    if eventObj.Operation = "Delete" then
    exit Sub
    End if

    Dim Value
    Value=eventObj.NewValue

    if Len(Value)>0 then

    if Value="false1" Then

    XDocument.DOM.selectSingleNode("/my:myFields/my:field2").text=""

    end if
    end if

    End Sub

    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 06-14-2006 01:32 AM In reply to

    Re: Problem in OnAfterChange code

    I try your Example and change it to this one:

    Sub msoxd_my_field1_OnAfterChange(eventObj)

    If eventObj.IsUndoRedo Then

    Exit Sub
    End If

    if eventObj.Operation = "Delete" then
    exit Sub
    End if

    Dim Value
    Value=eventObj.NewValue

    if Len(Value)>0 then

    if Value<>"good" Then

    XDocument.DOM.selectSingleNode("/my:myFields/my:field2").text=""

    end if
    end if

    End Sub

    Now, I run the form an enter in the field "good". Since the IF condition not happen (because "good"="good") the value "good" stay in the field. Now I change the value to be "bad" ,Since the IF condition is happen (because "bad" <> "good") the value "bad" in the field was replaced with "".

    Now (and here is the problem!!!!) I enter "test". the IF condition is happen (because "test" <> "good") BUT the value "test" was not replaced with ""!!!!!
    This is the problem!!!! why?
  • 06-14-2006 03:25 AM In reply to

    Re: Problem in OnAfterChange code

    Hi,

    I have one question for you,

    Text entered field(good/bad) and target field(i.e, setti g value " " or text ) are two different fields or one field.

    If it is one field, it will not work for you(it will go infinite loop, we have to add one condition at the starting),
    If they are two different fields, it is easy to do,

    Below code for one field, it is worked fine for me.

    Sub msoxd_my_field1_OnAfterChange(eventObj)

    if XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = " " then
    exit sub
    End if

    If eventObj.IsUndoRedo Then

    Exit Sub
    End If

    if eventObj.Operation = "Delete" then
    exit Sub
    End if

    Dim Value
    Value=eventObj.NewValue

    if Len(Value)>0 then

    if Value<>"good" Then

    XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = " "
    end if
    end if

    End Sub

    Thanks
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 06-14-2006 04:43 AM In reply to

    Re: Problem in OnAfterChange code

    This is about one filed (the filed that I oparate OnAfterChange evevt). I other word I try to do action of OnBeforeChange event in a OnAfterChange event.
    In my code example "fiels2" is the same field as "eventObj"
  • 06-14-2006 09:10 PM In reply to

    Re: Problem in OnAfterChange code

    What is the condition I need to add at the starting??
  • 06-14-2006 11:30 PM In reply to

    Re: Problem in OnAfterChange code

    Hi,

    Did you test the above code.

    I added condition in the above code to not enter into infinite loop of Onafterchange event,

    if XDocument.DOM.selectSingleNode("/my:myFields/my:field1").text = " " then
    exit sub
    End if

    Thanks.
    K.Ramana Reddy / http://www.ggktech.com
    India.
  • 06-15-2006 12:32 AM In reply to

    Re: Problem in OnAfterChange code

    Still not work. I will tell you somthing. I wanted to operate OnBeforeChange event (for this field), But I coludnt do it since in my event's code I call to a DataConnection (to a Web Service that recive paremeter) and this code line (of sending parameter to the WS):

    dataDom.selectSingleNode ("/dfs:myFields/dfs:queryFields/tns:EntryRequest_CheckExist/tns:strId").text=strId

    Can not be done since in OnBeforeChange event all the DataSource are in Read only status!!!

    That's why I use OnAfterChange event!
Page 1 of 1 (12 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.