Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

Query Data Source

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mdsmitty - 19 May 2005 18:41 GMT
I have a form that is querying a data source by using an account number and
the problem I have is that data is appearing in the data fields without an
account number (the 1st entry in the data source is what is populating the
data fields before an account number is entered).  Once I add an account
number to the field manually and tab out/leave the field the data fields
update.  The following is how I created the form.

1.  Created a form with a data source.
2.  Went through the data connection wizard, selected the tables to be used,
and began designing the form.
3.  The design defaults with a Title table, New Record Button, and Query
Button.
4.  I deleted the two buttons because I am going to populate the fields
automatically based on what is in the Account_Number field.  This field will
be populated programmatically in the .xml file before it is loaded.
5.  Created a query On Load Event to query the data source based on the
Account_Number field.
6.  Added a Rule - Condition: Account_Number is Present - Action: Query
using a data connection: Main connection.  In the Account_Number Properties
dialog.

The way I want the form to work is to have the account number populate
before the form loads, then upon loading the form the query will run
automatically.  If there is no account number in the Account_Number field
then no data should be populated in the "data fields".  The bottom line is -
If there is no Account Number then there should be no information in the data
fields.  When I enter an account number either manually or progammatically
then data should be queried and populate the data fields.

Thanks in advance

Mike

Scott L. Heim [MSFT] - 19 May 2005 19:34 GMT
Hi Mike,

Here are the steps I followed that appear to work:

- Created my sample from the Northwind Shippers table
- Added the "ShipperID" field from the "queryFields" to the Query section
- Added the Shippers table from the "dataFields" section to the Data section
- Added a Rule on the ShipperID "Query Field" that executes the query if
the ShipperID field "is not blank"
- In the OnLoad event of my form, I set the value of the ShipperID "Query
Field" using the following:

Sub XDocument_OnLoad(eventObj)
    Dim nodeShipperID
    Set nodeShipperID =
XDocument.DOM.selectSingleNode("//dfs:myFields/dfs:queryFields/q:Shippers/@S
hipperID")
    nodeShipperID.Text = 3
End Sub

So now when I open this form, the ShipperID "Query Field" is populated with
a 3 and the form only displays that record. If I then modify the value, the
form requeries and displays the appropriate record.

I hope this helps! :-)

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
Patrick Temple - 03 Aug 2005 16:42 GMT
Scott,

I understand what you did there but you manually set the shipperID in the
code.  How do I pass a value for shipperID to the form when I open it.  
Example:  I have a list of several requirements with unique values.  I want
to make a hyperlink that will open the InfoPath form and pass the value of
that requirement to InfoPath.  Then the form could query the database for the
information.  This worked real slick in Sharepoint when we were using XMl
forms but when we converted to SQL database this functionality was lost.  

--Patrick

> Hi Mike,
>
[quoted text clipped - 28 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.