Date Picker required! - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Date Picker required!

Last post 11-11-2004 12:03 PM by sakieboy. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 11-08-2004 11:46 AM

    Date Picker required!

    Currently all my DatePickers on my InfoPath form are required, or expecting the datetime format (red asterick). I want to be allowed to leave these fields as blank. I'm using SQL - Web Service (which contains my Dataset) and InfoPath. I'm basically passing an empty value, thus the DatePicker will not display anything if I select someone from my Query list. The problem is, that I'm not able to submit the form because it expects data to be in the Date Picker (to which I will not give it, because it's not required.)


    Thanks


    Darryl
  • 11-09-2004 02:18 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    Tough! :)

    I'm guessing in your DB you're allowing NULL for these fields (coz you can't have an "empty" value for a date). Exactly the same issue arises for any field type which does not allow an "empty" value (e.g. a string can be "", but an integer must have an integer value, or you can allow NULL, but it can't have an "empty" value as an integer).

    That means that IP marks the field as compulsory. According to me, with a dataset, the only way you can handle this is what I have had to do: you need to place the date picker in an "Optional Section". Either the user chooses not to bother with it (in which case it gets value NULL/DBNull), or s/he creates the optional section, and then the date is compulsory. It's a bit ugly, but if you fiddle with the layout of the optional section a bit you can make it not take up much more room than the underlying date control. Also, I get rid of "insert/delete" for these from the context menus etc. (via "Customize Commands", all except "Shortcut menu" for "Remove").

    I stand to be corrected by Greg, but I think that's it.

    Keep in touch, sakieboy, as it seems to me that those of us dealing with datasets/webservices have issues not faced by many IP users.

    Also, have you seen my reply to your old post in MS IP communities "Subject: RE: HOWTO send a dataset to webservice?"?
  • 11-09-2004 05:58 AM In reply to

    I just checked out your reply, and figured out the solution (not sure how though). Anyway, back to the topic at hand....Compulsory ahhhh...reminds me of the old Doc1 days with iterations, etc....(hated it!!!!). Also, I forgot to mention, I currently have set the Tools --> Form Options --> Edit Default Values --> my originally green checked date is no longer green, I notice that by unchecking the date it gets rid of the initial requirement for the field. I'm not sure if I need to set this back for the Optional Section. Speaking of Optional Section, I just tried it, and used my Date as the Data Source and it is still not working. The Customize section that you mentioned, I found out where it's at, but I'm not exactly sure what you are attempting to tell me regarding this.

    Oh boy.....Just saw something on the MS forum site, where someone is circumventing the date, but in the reverse way that I want. I could right before I do my query, set the dates (if empty) to 1900-01-01T00:00:00 (hun, hun, hun). In my Update and Insert Statement in SQL check for this string, and act on it accordingly. Let me know what you think about this, and please specify drawbacks if possible.

    As you see, this is a bug, that really doesn't make sense, it appears to be too many assumptions going on, thus causing more coding, to bypass the assumptions.


    Thanks
  • 11-09-2004 06:21 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    Now I don't follow what you're saying!

    Before we go any further, could you please clarify what you want/allow in your DB? What does "blank" mean? SQL can't store a "blank" date. Do you or do you not allow NULL/DBNull for your date?

    Also, do you want to give a link to look at whatever post you were referring to elsewhere?
  • 11-09-2004 06:31 AM In reply to

    Before we go any further, could you please clarify what you want/allow in your DB?
    NULLs are allowed in my date fields. Thus, they are not required.

    What does "blank" mean?
    Currently, when I select a record, the Date Picker doesn't have anything in it. I want to keep it that way (unless, of course, they select a date).

    SQL can't store a "blank" date. Do you or do you not allow NULL/DBNull for your date?
    I do allow NULL in my dates.


    The problem is that I can't submit, unless something is in the date.
    The previously mentioned solution is sounding a little better, although I would be better served handling the date/no date issue within the Web Service.
  • 11-09-2004 09:14 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    Then you should be in the same situation as me.

    In which case, according to me, you have no choice but to go my "Optional Section" solution, given that you're using a dataset. I see no other solution, and it does work.

    If you know of other, let me know (e.g. you seem to be talking about a post you saw elsewhere, I'd be interested to read, 'coz I don't think it can be done).

    What I'm claiming (with a dataset) is, if you make it optional:
    * if the user declines/deletes it, you get NULL/DBNull
    * if the user accepts it, the date is then compulsory (red asterisk) and must be filled in
    * if you don't make it optional, it won't work (if the field starts non-null it'll be compulsory if you try blanking it, and if it starts null you won't be able to get at the date picker at all!!)

    Let me know....
  • 11-09-2004 11:10 AM In reply to

    What I'm currently doing is attacking the dataset over in the Web Service. For instance, if they do not enter a date, I am populating the date with "19000101T00:00:00". In InfoPath:
    Dim myNode As IXMLDOMNode = thisXDocument.DOM.selectSingleNode(NodeForMainDataSource & "Date1")
    If myNode.text = "" Then
    myNode.text = "19000101T00:00:00"
    End If

    In the Update and Insert section of my Web Service. I have a statement such as...in Web Service:

    Dim DefaultDateAndTime as String = "19000101T00:00:00"
    If myDataSet.Tables(0).Rows(0).Item("MyDate") = DefaultDateAndTime Then
    myDataSet.Tables(0).Rows(0).Item("MyDate") = System.DBNull.Value
    End If

    The only draw back to this is that once the user Submits the form, the date 01/01/1900 appears in the date boxes, although it doesn't update the database, which looks kinda tacky. I tried to set it back to null (blank), but it wouldn't let me since it's in the "Been Submitted" state.

    I'll use it, unless I can figure out how to set up the Optional Section. Although, it's actually not an Optional Section. This section will appears everytime, and you have a choice to enter information into the field or not. In actuality, I'm dealing with signatures (a name and date). I have 4 signatures with dates. If one person signs it, I only want that persons information to be updated. If the second person signs it, I .... etc.
  • 11-10-2004 12:55 AM In reply to

    • jonbrave
    • Top 200 Contributor
    • Joined on 10-15-2004
    • United Kingdom
    • Posts 59
    I'm intrigued now. I *thought* I knew what I was talking about, but you obviously have something working I don't understand.

    What about my comment:
    * if you don't make it optional, it won't work (if the field starts non-null it'll be compulsory if you try blanking it, and if it starts null you won't be able to get at the date picker at all!!)

    e.g. to take one case, I find if I'm updating a row which currently has NULL in the field, I see the field, I see the date picker, but clicking it has no effect(!) --- because the field "isn't there".

    Are you saying this is not the case for you???

    I might prefer your "blank" solution, but I don't see how it works at all.

    Also, you have never clarified what you saw elsewhere ("Just saw something on the MS forum site, where someone is circumventing the date, but in the reverse way that I want"). Link?

    I've emailed you in case we would be better discussing this out of this discussion board.
  • 11-11-2004 05:47 AM In reply to

    I was out sick yesterday....It may take me about an hour to get my thoughts together....I just posted something, and when I went back to view it, of course, it didn't get posted. Anyway...

    What about my comment:
    * if you don't make it optional, it won't work (if the field starts non-null it'll be compulsory if you try blanking it, and if it starts null you won't be able to get at the date picker at all!!)


    e.g. to take one case, I find if I'm updating a row which currently has NULL in the field, I see the field, I see the date picker, but clicking it has no effect(!) --- because the field "isn't there".

    Are you saying this is not the case for you???

    I might prefer your "blank" solution, but I don't see how it works at all.


    This issue can be resolved by ---> In the Web Service, within the dataset, change your readonly property to Default, chances are it's currently set to true, which will not allow you to input information into a field (for obvious reasons)

    Also of note, in IP --> Tools -->Form Options --> Edit Default Values --> you should have a green check by your date fields. If you take the green check off, you'll notice that the red asterick no longer appears for the field. This is only the case when the form first displays.

    Also of note 2, if this doesn't work, my select portion of my SQL statement looks like this
    CASE ApprDeptManagerDate WHEN NULL THEN '' ELSE ApprDeptManagerDate END AS ApprDeptManagerDate



    Also, you have never clarified what you saw elsewhere ("Just saw something on the MS forum site, where someone is circumventing the date, but in the reverse way that I want"). Link?

    http://www.microsoft.com/office/community/en-us/default.mspx?query=circumvent&dg=microsoft.public.infopath&cat=en-us-office-infopath&lang=en&cr=US&pt=6e98618b-8f9e-4724-8a45-96c336e31a25&catlist=&dglist=&ptlist=&exp=&sloc=en-us


    I've emailed you in case we would be better discussing this out of this discussion board.


    Let's keep it on the board in case others have similar issues.
  • 11-11-2004 11:04 AM In reply to

    I'm curious if in your data source, the dates appear as elements or attributes? If they are elements you should be able to have them nillable in the schema that InfoPath creates. If they are attributes then you are out of luck other than to set them as strings.

    If you are using a Web service, you might be able to have dates on the database end and strings on the InfoPath end. Then you just use a date picker control for those string attributes.

    Since InfoPath creates an XSD or two for your data connection, if they are elements and are not nillable, you can always manually edit the XSD and make them so. Just keep in mind that if you ever update your data connection that those changes will have to be reimplemented.

    Greg Collins [InfoPath MVP]
  • 11-11-2004 12:03 PM In reply to

    It appears like this:

    <xs:element name="ApprDeptManagerDate" type="xs:dateTime" minOccurs="0" />

    I changed it to:


    <xs:element name="ApprDeptManagerDate" type="xs:dateTime" minOccurs="0" nillable="true" />


    to see what happens, and I replaced my SQL portion of my statement

    CASE tEOR.ApprDeptManagerDate WHEN NULL THEN '' ELSE tEOR.ApprDeptManagerDate END AS ApprDeptManagerDate,

    with

    ApprDeptManagerDate

    It will not allow me to modify the date. It originally does, if I leave my SQL statement the way that it is (with the CASE statement).

    I'm really not having that much of a problem with this, except that my dates are being intentionally populated on the form (which I'm doing so that my dates get populated). This is being checked at the Web Service, and I'm not allowing the bogus dates "19000101T00:00:00" to be updated to the database, my more pressing issue is the Insert VS Update.
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.