473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Help constructing a query

I have a table of contacts tblCon that includes customers and sales
persons with the identity column ConID
I have a table tblLinks that contains links between contacts. It looks
like this:
ID Customer Salesman
1 123 678
2 456 901
3 789 901
where 123, 456, 789, 678, 901 are the ConID from tblCon. Salemen can be
assigned to more than one customer and customers can have more than one
salesman.

What I want to do is to create a contact detail form that includes a
combobox.
I want to populate the combobox so that when you open the combo box, it
is populated only with customers or salesmen which are not already
linked to the contact being viewed. For example, I open contact details
for salesman 901 and the combo box would only include customer 123
because 901 is already linked to 456 and 789.
The combobox has to consider that 901 may not yet be linked to any
customers and that it may be linked already to other customers that are
irrelevant.
I thought this was easy, and maybe it is, but I spent a lot of time
trying to construct this without success.

Nov 13 '05 #1
1 1192
<snip>
What I want to do is to create a contact detail form that includes a
combobox.
I want to populate the combobox so that when you open the combo box, it
is populated only with customers or salesmen which are not already
linked to the contact being viewed.
</snip>

Can't you do that with a left join?

SELECT ...
FROM Contacts LEFT JOIN Salesmen ON ...
WHERE ContactID IS NULL

or something along those lines? Or are you trying to union the two
sets together? If that's the case, you'd have one left join query for
each set and then just UNION [ALL] to create one result set.

Or did I misunderstand the question?

if you can only populate the combo with Contacts XOR Salesmen, then I
would have another combo that set the rowsource of the one in question
through code.

Not sure if my reading of your question is right, but I hope this at
least points you in the right direction...

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: CaliSchmuck | last post by:
I think this is probably simple, but I'm having a problem figuring it out. I have a form that is used to enter data. I want users to be able to enter a zip code in the form, and have the city...
2
by: Jeremy | last post by:
I'm having some problems with using Server.Transfer and I am hoping somebody can help me. Page 1 has a datagrid, Page 2 has a form. If a user goes to page 1 and selects something out of the...
3
by: MattB | last post by:
Not sure if this is a good approach or not, but I'd like to hear some informed opinions. I've designed an ECommerce site that interfaces with my company's POS system. I'm trying to make it as...
2
by: Neil | last post by:
Hello I would appreciate if someone could help me with this query. I have an access database and am using ASP/VB. I have a table called 'booking' which contains the following fields: bookID...
0
by: xadrian | last post by:
Hi, I'm trying to put together a query that will order entries in a table by the rating values which decay over time. I'm not too well versed in the intricacies of Postgres, or complex queries,...
9
by: axlq | last post by:
I'm trying to figure out a MySQL query expression to match an email address. Here's the situation: User registers on my site with a "plus style" email address (username+key@example.com). This...
13
by: salzan | last post by:
I developed a query in query window and copied the sql statement as follows in my code... strSQL = "SELECT tblCategory.CatName, " & _ "tblDepartment.DeptName, " & _ ...
0
by: nagar | last post by:
I'm using SQLite with the ADO.NET 2.0 SQLite Data Provider as the storage of my application. I chose to use an untyped dataset and I'm using a dataadapter to report changes to the DB. The query...
0
by: Satish | last post by:
Hi everyone, I need some help constructing a linq query on datatables. I have 2 datatables as follows RangeTable MinValue MaxValue 0.00 0.050 0.051 0.10 0.101 0.15 0.151 0.20
4
by: CK | last post by:
Good Morning All, Can use use a variable for the FOR clause in a cursor? Example I have DECLARE @a varchar(50), @b varchar(50), @c varchar(50) DECLARE @sql varchar(255) DECLARE @x...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.