Infopath - Display data from a database - InfoPath Dev
in

InfoPath Dev

Infopath - Display data from a database

Last post 01-29-2009 05:52 PM by Hilary Stoupa. 15 replies.
Page 1 of 2 (16 items) 1 2 Next >
Sort Posts: Previous Next
  • 10-09-2008 11:12 PM

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Infopath - Display data from a database

    Hi there.

    Am new to all this :-)

    I have a template file created based on an MS Access database.

    One of the controls on the form is populated with the function Username. 

    I have a main datasource, being the table in the access database where I wish to store the data from this form.

    I have a number of secondary data sources, being tables from the database used to populate combo boxes.

    Q1.  I wish to display on the form some information about the user.  That information is stored in a secondary datasource.  Exactly how do I achieve this ?

    Q2.  This form is a Purchase Order form.  Once it is completed, i wish to save the data in the database table (tblPurchase Orders), which i appear to be able to achieve successfully, however, i also wish to send the form, via email, to another person for them to "authorise", before the order is sent to the supplier.  How to I disable the authorisation section for all users, other then the recipient of the email - ie the person who needs to approve the order form ?  I currently do not have a field in my database in the tblUsers table that indicates a person can approve orders.  Do i need one ?

    Regards Gary

     

  • 10-10-2008 06:45 AM In reply to

    Re: Infopath - Display data from a database

    For 1.

    I am assuming you would want a repeating table or section.  Drag you r secondary onto the view to create it. Then add conditional formatting to hide all but where username matches username in your main data.

    For 2.

    Yes you would want to use the approve field to control whether the button to approve is enabled or visible, etc.Again this is done in conditional formatting.

    I would recommend you just send the approver a link and they open a new form and query the data again, or make sure your form requeries each time it is opened so you do not have data that is not current being sent to people and potentially overwriting newer data.

  • 10-12-2008 03:15 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Thanks for the reply.

    For 1

    I did not see this as being a repeating table or section.

    I have a field UserID whose contents is the function username.  I wish to have a couple of other fields to display the user's telephone number and email address.  These 2 pieces of data are found in the table tblUsers.  How do I use conditional formatting as you have suggested ?  Specifically what is the condition and/or function ?

     

    For 2

    I believe you are saying that in my table that contains the names of those who are authorised to "approve" a purchase order, I need a field named "Approver" and the data in that field would be a yes or no.

    I then need to set the name of the approver and a corresponding "approved date" field as visible = false, unless the username = approver name in which case I would set the "approved date" as visible.

    How do I send the approver a link programatically ?

    How do I set the display fields as visible = true or visible = false ?

     

  • 10-12-2008 05:21 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Another way of looking at what i am trying to do is as follows:-

    Requestor                 Contact Number    Contact Email
    gary.burke                 614 123 456          [email protected]
     
    I get the Requestor's name from the function userName.
    I now wish to merely display that user's contact number and email address.  In an attempt to achieve this, i have inserted 2 expression boxes (1 for each field).  The data for these 2 fields is found in a table in an Access database called tblUsers.  The connection to this table is a secondary data source called Users.
     
    I would think that the data could be retrieved by filtering as follows:-
    @UserPhoneNumber[@UserID = POUserID]   
    POUserID is the data used for the Requestor
     
  • 10-12-2008 10:49 PM In reply to

    Re: Infopath - Display data from a database

    That looks correct.

    I would have a field that defaults to Username(), I am assuming that is the UserID.

    So your formula looks correct.

    Have you put UserID on the form to verify what is coming across?  USername gets the local username not the domain account.  That is one limitation that I prefer an AD web service for so that it works with VPN users and etc.

     

  • 10-12-2008 10:59 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Actually the POUserID is populated with the userName function.

    The UserId is the field in the secondary data source.

    The formula is trying to say "find the phone number in tblUsers (in Access) where its UserID (an indexed field) = the POUserID (as found on the form).

    I do not get an error, but no data is returned.

  • 10-13-2008 07:32 AM In reply to

    Re: Infopath - Display data from a database

    The filter in your XPath looks correct for what you are trying to do. I'm sure you've done this, but do verify that your user name is in your access DB exactly as it is being returned in the form (one way I do this is to write a query in my DB and copy and paste the contents of my text box directly into the 'where' clause).

    Hilary Stoupa

  • 10-13-2008 08:04 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    All working just fine now......I suspect my problem was that my "where" clause was not querying the correct field :-)

    Thanks for your help

  • 10-13-2008 11:18 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Sorry...I jumped the gun. :-)

    All works fine until I introduce a repeating table.

    In that section I have Quantity and Unit Price.  These two fields are linked to my main data connection.  Naturally I wish to extend the total for each row in the table, and to then have a Grand Total for all rows (of just the extended total).

    My next part will be depending upon the value in the Grand Total, I will need to do x or y, so i will need to reference this value.

    I have tried text box, but that has to be bound to a field in my data connection, and I don't have one, nor should I have one (its not good programming to have extensions stored in a database table, they get calculated when needed).

    I have tried an expression box, but then how do i add these to obtain a Grand Total ?  Plus it would appear that each expression box contains the same values, on each row, irrespective of the Quantity and Unit price used on each row.

    Looking forward to your assistance once again.

  • 10-14-2008 07:07 AM In reply to

    Re: Infopath - Display data from a database

    So an expresssion box with the formula Quantity * UnitPrice (with your fields, of course) placed in a column in the repeating table doesn't bring back the per row total price?

    For the grand total you could use sum(field) * sum(otherfield). I'm attaching a quick sample to this post, okay?

    Hilary Stoupa

  • 10-14-2008 03:28 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Thanks so much for the example however, I need a username and password :-)
  • 10-14-2008 03:33 PM In reply to

    • Gary Burke
    • Not Ranked
    • Joined on 10-10-2008
    • Brisbane, Australia
    • Posts 10

    Re: Infopath - Display data from a database

    Hi Hilary,

    I have been able to get into the form....however, the Grand Total did not calculate correctly.

    I put in 10 in the 1st column and 20 in the 2nd column - the total calculated correctly on the row as 200

    I then inserted a new row and put in 20 in the 1st column and 30 in the 2nd column - the total calculated correctly as 600 on the row.

    However, the grand total was incorrect at 1500.  It should be 800.  The grand total is adding the 1st column together (10+20) and then multiplying that by the total of the 2nd column (20+30) - ie 30*50

  • 10-14-2008 04:06 PM In reply to

    Re: Infopath - Display data from a database

    Math is definitely not my strong point. I'm attaching the template again, this time using sum & eval, see if this helps.

    The formula is sum(eval(group2, "my:field1 * my:field2")). Note that with eval, you can select the group with Insert Field or Group, but must type the expression in manually.

    Hilary Stoupa

  • 01-29-2009 07:17 AM In reply to

    • clawrence
    • Top 500 Contributor
    • Joined on 11-07-2008
    • Birmingham, AL
    • Posts 38

    Re: Infopath - Display data from a database

    I am trying to do this in a form I'm working on, but I keep getting the error "does not point to a valid location path of a field or group."  I'm trying to use the Quantity and LowestCompetitivePrice fields in the LineItems group of the data source shown below.

    DataSource

  • 01-29-2009 08:16 AM In reply to

    • clawrence
    • Top 500 Contributor
    • Joined on 11-07-2008
    • Birmingham, AL
    • Posts 38

    Re: Infopath - Display data from a database

    Nevermind, I got it.
Page 1 of 2 (16 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.