Button that sets textbox value to current time on click - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Button that sets textbox value to current time on click

Last post 05-19-2010 09:15 AM by rtree. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 05-17-2010 11:17 AM

    • rtree
    • Not Ranked
    • Joined on 05-17-2010
    • Posts 3

    Button that sets textbox value to current time on click

    Greetings, I am new to Infopath and jscript. I don't have much code writing experience other than some VBA in Excel and Access.

    I would like to create a button that sets a textbox (bound to Access) to the current time and date. I am using the 2003 versions of Infopath and Access.

    I have pieced together some bits and pieces based on what I read in other posts:

    Code after the button is clicked

    function cmdStartTime::OnClick(eventObj)

    {

         XDocument.DOM.selectSingleNode("my:myFields/my:dataFields/my:PM_History/my:Start_Time").text = Now();

    }

    I have linked to an MS Access database, and my data source tree to reach the field I want to change looks like:

    myFields

    dataFields

    d:PM_History

    Start_Time

     

    If someone could nudge me in the right direction, I would greatly appreciate it!

    Filed under:
  • 05-19-2010 01:35 AM In reply to

    Re: Button that sets textbox value to current time on click

    why dont you use rules instead and set the value of the field to now()

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-19-2010 03:28 AM In reply to

    • rtree
    • Not Ranked
    • Joined on 05-17-2010
    • Posts 3

    Re: Button that sets textbox value to current time on click

    Thanks for the reply, I could use Now() for when the form is opened but not when they finish completing the form.

     I forgot to mention that I have two fields (start and finish) that need to be populated with the time.

    This is for a maintenance check sheet. The maintenance supervisors do not want the technicians to write in times earlier than the present time.

    The button is to save the user time since not all of them type quickly. My fall back plan if I can't get the button to work is to try field validation rules and have them type in the date and time.

  • 05-19-2010 05:57 AM In reply to

    Re: Button that sets textbox value to current time on click

    on button click create a rule to set the value of the field to now(), instead of doing the same through code

    Qazi Anis
    Technical Architect
    Bitwise Inc
  • 05-19-2010 09:15 AM In reply to

    • rtree
    • Not Ranked
    • Joined on 05-17-2010
    • Posts 3

    Re: Button that sets textbox value to current time on click

    Perfect! Thank you sir!

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