Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Infopath
Infopath Programming and automation discussions only please. :)
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Infopath section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 21st, 2007, 03:16 AM
Registered User
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query criteria from two tables in main connection

I need to be able to generate a query that uses conditional criteria from two different tables (one a subsidiary of the other).

I have two tables :

Project Details
    Project Id
    Project Description etc
    Area Id

Contact Details
    Contact Id
    Project Id
    Contact Name etc

I need to be able to be able to query on any of the combined fields .

Example Queries :

1) List all Projects (plus the Contact Details for the Project) where the Contact Id is 5.

2) List all projects that have an area Id of 5 and where the Contact Id is 2.

And so on …………………..

I am using Infopath 2003 and I can not achieve this simple requirement.

Nor can I find any examples in books or on the net.

I have tried to do it through the form handling, through code behind buttons etc …………

Can someone please provide some expertise in this area?

I have created a main connection that has the two tables related together.

If I create the query fields from the main connection, then the query will successfully create the query on the main table (Project Details) and the Contact Details Query conditions will apply to the subsiduary table Contact Details.

I want to return back project details for all entries that have contact id 5 (and maybe some additional conditions on the main table).

If I just enter contactId 5 as the criteria, I get the entire main table returned and then just the contact ids that have 5.

I want the query to find the Project Details where there is a related contact id of 5.


Select * from ProjectDetails where ProjectId in (select ProjectID from ContactTable where ContactId = 5)

Naturally the 5 comes from the form control value.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional criteria in query dfuas Access VBA 1 January 21st, 2006 03:46 AM
Conditional criteria in query dfuas BOOK: Beginning Access VBA 0 January 15th, 2006 03:19 PM
Criteria in Query lryckman Access 1 June 23rd, 2004 11:11 AM
2 Tables - 1 Statement - 1 Output - 1 Criteria sencee PHP Databases 7 May 25th, 2004 04:53 AM
Query Criteria Clive Astley Access 4 March 25th, 2004 03:27 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.