Need to hide the "data" section when records are not returned when queried - InfoPath Dev
in

InfoPath Dev

Need to hide the "data" section when records are not returned when queried

Last post 08-07-2009 07:39 AM by RhysAZ. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-24-2009 03:31 PM

    Need to hide the "data" section when records are not returned when queried

    Quick question-

    I am using IP2003 and I am connected to an Access 2003 d.b. My form has the "query section' and the "data" section. I want my "data" section to be conditionally hidden at the form opening. Then, when the user queries the database from a selection in the "query" section (such as a "date") and no record is returned for that "date", I want a message telling the user that no record was found (similar to the message when you use the Run Query button and no data was found), keep the "data" section hidden, and force the user to select a button or link (just like the Option Section) that will then open the "data" section so they can enter a new record.

    I want to do this so the particular user can't add a new record to the database if they have already entered a record with the same date.

    I have 9 Repeating Group tables, with one table as tblMain that is tied to the other eight tables in a one-to-many relationship.

    Can someone please tell me how this can be done using controls (Sections, Repeating Sections, Optional Sections, etc), conditional formatting, and with rules?

    I've almost accomplished what I want but not quite. So, the request for help to do it properly.

    Thanks in advance,

    RhysAZ 

     

     

     

     

     

     

     

     

  • 07-27-2009 12:27 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    Do you mind adding additional fields to your main data source in the template to help with this? You don't have to add them to the tables in your Access database....if you right-click on the root of your main data source in the data source task pane (probably myFields), you can add fields.

    You could have a field (for example) called 'ShowData' and have an open rule that sets it to false. Then conditionally format your data section to not show if 'ShowData' is false.... Your button you use to run a query could include a rule to set ShowData to true if the count of the data nodes is greater than 0....

    You could add another field for showing your message, ShowMessage, and have it be set to false in the open rules. When you run your query, if the count of the data nodes = 0, you could set 'ShowMessage' to true. The button you want the user to click for adding a new record could be in the same section as the message you want to display. Format that section not to show unless ShowMessage is true....

    Hilary Stoupa

  • 07-27-2009 02:14 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    Hi Hilary- No I don't mind adding the fields. Couple of questions:

    1. Should these new fields you say to add be a Field(element) type and Text (string) data type or True/False data type?

    2. When you say "run a query could include a rule to set ShowData to true if the count of the data nodes is greater than 0...." can you give me an example what the rule would look like? The "count of the data nodes is greater than 0" is what's throwing me.

    3. When you say "The button you want the user to click for adding a new record could be in the same section as the message you want to display..." I am assuming you want me to make a section just for that button, that is bound to the Show Message field, right?

    RhysAZ 

     

  • 07-27-2009 02:47 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    Generally, if I am adding fields for showing / hiding data, I'd make them True/False. I think that's simpler.

    For item 2, I've attached a screen shot -- in your rule condition, you'd select the repeating data field from your main data connection (/dfs:myFields/dfs:dataFields/d:tableName) and then in the Select drop down, choose 'Number of occurances'. If the number of occurances of that group = 0, you'd set 'Show Message' to true, for example. Since the data section won't show if there aren't any results to your query, you probably won't have to do anything extra to hide that, if you have hidden it on open.

    As to 3, I just meant that if you were using the 'New Record' button if nothing was returned by the query, you'd want to put that button in the same section with your message about no query results, so it will hide with the message if there are query results...


    Hilary Stoupa

  • 07-27-2009 03:26 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    Thanks, I understand now. FYI- As for the new fields, I tried adding the ShowData field to myFields as True/False, set its default as blank, added an Open rule to set it to FALSE, and conditionally formatted the Section within the "data"section to hide if ShowData was FALSE. It had no effect. 

    But, I think I can utilize what you've told me to make it work. I will let you know how it turns out Hilary. Thanks a bunch!      RhysAZ

     

  • 07-27-2009 03:37 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    "It works on my machine" is a lousy answer, but it does... In your open rule, when you set ShowData to false, click the fx button and open the formula editor and use the 'false' function (or type false() into the formula editor). I know in the conditional formatting it shows FALSE all in caps, but I think if you are setting the value of a boolean to text in IP, you'd want to set it to all lower case 'false'. This would explain why I like to use the function from the formula editor....

    Hilary Stoupa

  • 07-28-2009 12:14 PM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    Yeah, that did it, it worked! Now to implement #2 and #3...

    Thanks Hilary! 

     

  • 08-07-2009 07:39 AM In reply to

    Re: Need to hide the "data" section when records are not returned when queried

    #2 and #3 worked as well. Thanks again Hilary.

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