More questions: Do you use the form to submit changes back to the database?
And when does the date comparison take place? You said previously that you
created a rule? Where did you do that?
I thought you made the changes in the database (which what my suggestion was
all about) and then created the form again. Obviously, you made the changes
within InfoPath, so I'm not sure what's going wrong right now. It is best to
revert back to your original SQL statement for now.
Give me a day or two to think about your scenario. I might come up with a
way to solve your problem without any major changes.
---
S.Y.M. Wong-A-Ton
:
Ok, here goes.
I have an Access database with several tables. A couple of the tables are
used as lookup tables (secondary data sources) for some dropdown fields. I
have 2 main tables that are related (T_Filing and T_Action_Items) -
one-to-many relationship.
When I created my form I did it by going through the create InfoPath form
based on data source. The data source being an Access database - the main
table is T_Filing and using the add table button I added the T_Action_Items
table. This is my main connection. The code for that connection is:
shape
{select
[Filing_ID],[Company_Name],[State],[Product_Area],[Line_Of_Business],[Filing_Type],[Delay_Adopt],[File_Date],[Effective_Date],[Filing_Method],[Filing_Description],[Disposition_Type],[Disposition_Date],[Disposition_Description]
from [T_Filing] as [T_Filing]} as [T_Filing]
append
({select
[Action_Key],[Filing_ID],[Action_Date],[Action_Initiated_By],[Action_Type],[Action_Description] from [T_Action_Items]}
relate [Filing_ID] TO [Filing_ID]) as [T_Action_Items]
It's important that I understand any changes to the above statement because
I also have some VBScript code related to a button that queries the database
for a specific filing.
Basically the first page of my form is a search view that returns a couple
fields regarding each Filing. From here a user selects a Details button - to
see all the Filing details for the selected Filing. In order to do that I had
to write my own SQL. Same statement as above but with an additional Where
clause.
I received the Tree View message when I went into my main connection
(Tools/Data Connections/Main Connection/Modify/Edit SQL). After I edited my
SQL statement - changed [File_Date] to Format(T_Filing.File_Date,
"yyyy-mm-dd") As File_Date. I hit the Test Sql button and received the dialog
box stating the test was successful. When I clicked the Ok button I received
the Tree View warning message then in the Data Source view on the Design
Tasks pane all my query fields disappeared. Then I clicked Next to finish up
the data connection changes and received a warning dialog box stating Access
can no longer determine if this query is safe - click Yes to continue.
Thanks for the help!
--
-ridawg
:
The plot thickens...
Let's back up for a while, shall we? Can you explain from the start - in as
few words as you can - how you set up your form? You are using MS Access,
right? And when do you get that "tree view" error? In InfoPath or elsewhere?
Perhaps you can post the shape SQL statement (and mask/change sensitive field
names), so that I can try to reconstruct your query and form?
Sorry I cannot offer more help/advice at this time, but my hands are pretty
much tied until I fully understand your scenario...
---
S.Y.M. Wong-A-Ton
:
I gave this a try but I'm running into problems. Here's what happening:
When I edit my query to add the formatting and test the SQL - no problems.
But the next message I get after editing the SQL states that it can't
represent the SQL in the tree view. Not a big deal but after clicking ok all
my query fields disappear. So I can see my data fields (the date fields are
converted into simpletype data types and I thought they would be converted
into date datatypes).
Not having the query fields essentially makes the form useless.
So do I need to completely re-write the SQL statement? Something to be aware
of is the database I'm connected to consists of 2 tables so my SQL statement
also includes the shape command. Not sure if that might be throwing things
off.
--
-ridawg
:
Yes, so far so good. No need to implement the comparison like on my site,
since your method should work. Try it out and let me know.
---
S.Y.M. Wong-A-Ton
:
I think I understand what you're getting at but let me run this by you.
My database date fields are all setup as date/time datatypes and as a result
my InfoPath form fields are setup as optional_dateTime datatypes. But
InfoPath stores the date differently internally so this is likely why my
comparison validation isn't working. Plus I'm not actually using time.
So in order to fix this I think all I need to do is edit my SQL statements
to correct the format. For example, Format(MyTable.File_Date, "yyyy-mm-dd")
As File_Date, Format(MyTable.Action_Date, "yyyy-mm-dd") As Action_Date.
From there I should be able to use the validation rule that I've already
created (Action Date < File Date) because I'm assuming both fields will come
through as date datatypes that InfoPath can work with or I may need to use an
expression like you outline on your site.
Does my thought process make sense on this?
--
-ridawg
:
I think the problem is in the database field's date/time format you are
using. You must make sure that the date format in your database is the same
as that used by InfoPath in the background, otherwise you'll get
unpredictable results like you are getting right now when trying to compare
dates.
Refer to this article
http://enterprise-solutions.swits.net/infopath/date-time-basics-infopath.htm
to find out how InfoPath uses dates behind the scenes.
Refer to this article
http://enterprise-solutions.swits.net/infopath/filter-repeating-table-date-range-rules.htm
to find out how you can change the format of the date field in your database
to suit InfoPath for date comparison.
---
S.Y.M. Wong-A-Ton
:
Hey,
I have a form with two date fields. The first field is called File Date and
the second field is called Action Date. I tried to create a Data Validation
rule on the Action Date field that states Action Date < File Date.
Esssentially, saying pop up a an error message - Action Date can't be less
than File Date.
The problem I'm having is when the Action Date and File Date have the same
date the error message pops up. This isn't correct - it should only pop up
when it is less than the File Date. If they are equal that's fine.
Not sure why this is happening. Both dates are entered in the form by the
user. The form is tied to a backend database. Both fields are setup as
optional_dateTime types. The database fields are using the Date/Time datatype
and short date as the format.
Thanks!