Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / May 2007

Tip: Looking for answers? Try searching our database.

How to make a date picker field empty?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor - 24 Apr 2007 04:02 GMT
Hi,

  I have assinged a date into the date picker field at the beginning, then
i want to make the date pikcre field empty again programmatically, is it
possible? I have tried to put the date ficker field="" but it says must input
a date value. How? Is it possible to remove the date value after i have input
the date. I want to make the date picker field empty again by using program.
Is it possible?

  Thanks in advanced!

Rgds,
Victor
S.Y.M. Wong-A-Ton - 26 Apr 2007 11:14 GMT
When you programmatically set a date field, you need to remove the nil
attribute on it before you can set its value. When you programmatically want
to empty a date field, you need to add the nil attribute back to the date
field.
---
S.Y.M. Wong-A-Ton

> Hi,
>
[quoted text clipped - 9 lines]
> Rgds,
> Victor
Victor - 27 Apr 2007 04:18 GMT
Hi Wong,
 
   Thanks for replying my query. Really appreciate that.

   I still cannot get the answer. This is because how to programmatically
add the nil attribute back to the date field?

  Is it by using addAttribute or setAttribute?

 I tried both but the command after this method just won't execute. I don't
know why.

For example:

   var
nIssDate=XDocument.DOM.selectSingleNode("//my:myFields/my:Items/my:Item/my:IssueDate");
   
   
    if(!nIssDate.getAttribute("xsi:nil"))
    {
       XDocument.UI.Alert(nIssDate.text);           
       nIssDate.setAttribute("xsi:nil");
       XDocument.UI.Alert(nIssDate.text);           
       nIssDate.text ="";
    }           
   
  I can display the first    XDocument.UI.Alert(nIssDate.text);  but i
cannot display the second XDocument.UI.Alert(nIssDate.text);

  What's wrong? Why after i put the   nIssDate.setAttribute("xsi:nil"), the
message just won't display.

   Your help is very much appreciated.

Regards,
Victor
     

> When you programmatically set a date field, you need to remove the nil
> attribute on it before you can set its value. When you programmatically want
[quoted text clipped - 16 lines]
> > Rgds,
> > Victor
sMcd - 29 Apr 2007 17:16 GMT
I'm having similar problems.  I can get code to set/reset the xsi:nil attribute to work on new forms and/or the first instance of inputting a date, but it doesn't work when opening an existing form with a date already in the field.  I believe this is true because you cannot set attributes on existing xml nodes with data (if you can, I sure can't figure out a way to do it!) -- you can play with attributes as you're creating the node (i.e. as you fill out the form or enter data in a field), but not once it has been created.

Which brings us back to your problem, Victor, and mine.  How can you reset a date field to null after one has entered data and submitted/saved the form?

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
S.Y.M. Wong-A-Ton - 30 Apr 2007 01:42 GMT
Hey guys,

This topic has been discussed several times and there have been useful
threads/posts on the subject. Take a look at these two:

http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/af
828ed45264ed65/32e614e9fd246461?lnk=gst&q=xsi%3Anil&rnum=6&hl=en#32e614e9fd24646
1


http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/e2
f6ae494d00cb67/1225c0279e321790?lnk=gst&q=xsi%3Anil&rnum=8&hl=en#1225c0279e32179
0


Tip: If you find a post useful, rate it as such; posts usually disappear
(yearly cleanup or something similar) after a while if they have not been
rated. You can always find old posts back - as I did - via Google groups,
though, whether they have been rated or not.
---
S.Y.M. Wong-A-Ton

> I'm having similar problems.  I can get code to set/reset the xsi:nil attribute to work on new forms and/or the first instance of inputting a date, but it doesn't work when opening an existing form with a date already in the field.  I believe this is true because you cannot set attributes on existing xml nodes with data (if you can, I sure can't figure out a way to do it!) -- you can play with attributes as you're creating the node (i.e. as you fill out the form or enter data in a field), but not once it has been created.
>
> Which brings us back to your problem, Victor, and mine.  How can you reset a date field to null after one has entered data and submitted/saved the form?
>
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
S.Y.M. Wong-A-Ton - 30 Apr 2007 01:48 GMT
Victor, try createAttribute() or createNode() to create the attribute on the
date field (also see my reply to sMcd's post and the SetNil() jscript
function in the sample Absence Request form that comes with InfoPath).
Remember that you also have to give the attribute a value of "true".

Hope this helps.
---
S.Y.M. Wong-A-Ton

> Hi Wong,
>    
[quoted text clipped - 54 lines]
> > > Rgds,
> > > Victor
Victor - 03 May 2007 01:52 GMT
Hi Wong,

    Thank you so much for providing me such a useful help tips! I managed
to set the date picker field to be empty after i have input a date and save
it by using setNil() function from the Absence Request form sample. The
Absence Request Form sample really has a lot of functions to offer. I must go
through the code to find out more to be used for my future problems
encountered.

    I have solved my friend's problem on making date picker field empty.
Now, i would like to solve my problem on how to count numbers of records when
there are two conditions applied which i have posted it under title "How to
count with two conditions?".

   Please help me to take a look at the question to see if you can find out
a solution for me while i work it out myself too.

   Thank you so much!

   
   Regards,
   Victor

   

> Victor, try createAttribute() or createNode() to create the attribute on the
> date field (also see my reply to sMcd's post and the SetNil() jscript
[quoted text clipped - 63 lines]
> > > > Rgds,
> > > > Victor
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.