MS Office Forum / General MS InfoPath Questions / August 2005
Infopath database forms - Many to many
|
|
Thread rating:  |
Marc Nemegeer - 09 Aug 2005 16:02 GMT Hi, I'm designing some small Infopath forms for managing a database. It is all very basic data. But now I'm stuck ...
I have to find a way to make a form for a many to many relationship.
I figured out I can make three forms, two for the basic data and one for the many to many relationship.
Is this the way to do it or is there a more intelligent way of doing this ?
Regards, Marc
Scott L. Heim [MSFT] - 09 Aug 2005 22:47 GMT Hi Marc,
I would like to ask some additional questions before making some suggestions:
- Are the tables of data related? (i.e. Customers -> Orders -> Order Details?) - If so, have you created "relationships" between the tables in the database itself? - Are you creating your InfoPath solution directly from the database (i.e. did you create a new form from the database?) - When you say you made three forms, are you talking about three different "views" in one InfoPath XSN file or three different XSN files? - What is the ultimate goal?
Thanks Marc,
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
Marc Nemegeer - 10 Aug 2005 07:55 GMT Scott, I'm building a user interface, as simple as possible to edit all tables in my small database. So yes, I'm generating from a database and the relations are in a database, the database is normalized. So,I have three tables, one who identifies a person with his name, one table who identifies a department and one table that creates the relation between these two tables.
And yes I have three infopath files.
I'm open to a suggestion to get to two forms, but all things I tried out, I was not able to get a submit button ...
Appreciate your help, regards, Marc
> Hi Marc, > [quoted text clipped - 17 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 10 Aug 2005 13:16 GMT Hi Marc,
Assuming you have the relationships established correctly, then you should be able to create one InfoPath solution that brings together all the required tables. Now with that said, are you familiar with the "Northwind" sample Access database? If so, let me provide an example. The Northwind sample database contains an "Order Details" table, which is the "join" table between the Orders table and the Products table. (There is a many-to-many relationship between Orders and Products - hence the Order Details table.)
If I were to create an InfoPath solution for this, I would *only* bring in the Orders table and the Order Details table...I would not need to include the Products table. Now, in my Order Details table there is a "Product" field so the user can enter a product. What you would do in this case is add a secondary data connection to the Products table and use a drop-down box that has this "Products" connection as its data source. This way, the user can select a product when entering a new "order detail."
So I guess my reasoning for my "soap box" <G> is to suggest that you *may* have a situation where you do not need to include all three tables when you build your InfoPath solution and may just need to include the third table as a secondary data source for a "lookup" field.
Obviously the above is just a thought process for a way to possibly re-design your application. There is another reason as to why you may not get the submit functionality: if your database tables contain data types such as: Memo, OLE Object, etc. If you have these data types, you will not be able to bind your InfoPath solution directly to the database - you would need to write a web service that retrieves/updates the data and bind your InfoPath solution to the web service.
Let me know if any of this helps! :-)
Best regards,
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
Marc Nemegeer - 10 Aug 2005 14:48 GMT Scott, This is exactly the solution I found. I was hoping to avoid a form with only a table of three columns, a key column and two drop down lists for each row.
I am wondering if there is an intelligent possibility to create a row in the related table (person) by entering the person field name and then selecting the department whereto this person is associated. Without to much scripting ...
Thanks, Marc
> Hi Marc, > [quoted text clipped - 36 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 10 Aug 2005 15:10 GMT Hi Marc,
If I understand correctly, you would like to be able to have the user either enter or select a person's name and then have the department field fill in automatically - is this correct?
If so, you can do this with a "Rule" where the rule would "Set a field's value."
Let me know if I misunderstood or you would like an example of how to do this.
Best Regards,
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
Marc Nemegeer - 10 Aug 2005 15:59 GMT Hi Scott, But then I would need two tables on my form which will disable my submit button. And yes I would be happy with a solution like the one you described below :-) So I guess an example would be helpfull ...
Thanks, Marc
> Hi Marc, > [quoted text clipped - 14 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights Scott L. Heim [MSFT] - 10 Aug 2005 16:44 GMT Hi Marc,
Here are sample steps using the Access Northwind sample database - if you can, please do complete these so you can see how this works:
- Create a new InfoPath solution based on the Orders and Order Details table (when you add the Order Details table you should automatically see the relationship based on the OrderID) - From the queryFields, drag CustomerID to the query section - From the dataFields, drag "d:Orders" to the data section and then choose "Repeating Section with Controls" - From the Tools menu, add a new data connection "Receive") to the Products table from the Northwind database. For this sample, you will only need to include the ProductID, ProductName and UnitPrice fields - Right-click on the Order Details Repeating Section, choose Change To and select Repeating Table - Right-click on the ProductID field in the Order Details Repeating Table and choose "Change To" and select Drop-Down List Box - Right-click on the ProductID drop-down and choose Properties - On the Data tab in the List Box Entries section choose "Look up values in a data connection..." - From the Data Connection box choose Products - Click the Select XPath button next to Entries - Highlight d:Products and click OK - In the Value box, leave this as: @ProductID - For Display Name, click the button, select ProductName and click OK (you should be now back to the Data tab on the Properties sheet) - Click the Rules button - Click Add - Click Add Action - From the Action box, select Set a Field's Value - Click the button next to Field - Insure the Data Source is set to Main - Drill down through the dataFields, select the UnitPrice field under Order_Details and click OK - Click the button next to Value - Click Insert Field or Group - From the Data Source box select Products - Drill down through the dataFields and highlight UnitPrice - Click the Filter Data button - Click Add - In the first box select ProductID - In the second box, leave this as "is equal to" - In the last box choose "Select a Field or Group" - From the Data Source box choose Main - Drill down through the dataFields until you can select the ProductID field under Order_Details and click OK - Click OK again - Now click Modify - From the first box choose The Expression - this will now show you the expression result of what we just completed and should look like this:
./@ProductID = xdXDocument:get-DOM()/dfs:myFields/dfs:dataFields/d:Orders/d:Order_Details/@ ProductID
- Modify this so it looks like the following:
./@ProductID = current()/../@ProductID
- Click OK 8 times to get back to the form in Design View - Preview the form - Enter BERGS as a CustomerID and click the Run Query button - Make a different ProductID selection in one of the Orders - you should see the Unit Price field reflect the price for the new product you selected!
I hope this helps!
Scott L. Heim Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights
Marc Nemegeer - 11 Aug 2005 13:29 GMT Scott, Thanks. You've learned me something :-) Marc
> Hi Marc, > [quoted text clipped - 68 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights
|
|
|