View Full Version : Complicated multi query issue


Sam Summers
10-28-2002, 01:13 PM
I have got so far but am struggling a bit just now.

There is no point in explaining, just read the attached document and try not to faint!!!

llkhoutx
10-28-2002, 01:23 PM
the followinbg part of the sql string

((EmployeeCert.Level)=IIf(IsNull([Forms]![MultiSearchTest]![IRATA]),[Level],[Forms]![MultiSearc

references [Level] and doesn't know what table you intend as [Level] occurs in more than one table.

Sam Summers
10-28-2002, 01:27 PM
Thanks for replying

So seeing as this is the Link table theres no real way around it apart from scrapping the 'Level' part of the search for this particular query?

llkhoutx
10-28-2002, 06:30 PM
Your using [Level] in a criteria without setting a value for same. Take it out of the WHERE (criteria) portion of your query and see if you get what the result you want.

Otherwise, you've got to give it a table identifier and a value. If you don't it's useless and causing confusion/.ambiguity in the WHERE.

Pat Hartman
10-28-2002, 07:26 PM
I have to admit, I did not read the query very closely. It was too painful with all the extraneous parentheses and long names. But the following change will probably fix the problem:

AND ((EmployeeCert.Level)=IIf(IsNull([Forms]![MultiSearchTest]![IRATA]),EmployeeCert.Level,[Forms]![MultiSearc hTest]![IRATA]))

To make long SQL strings easier to read, use alias names. For example:

Select a.AccountName, a.AccountRep, o.OrderTot
From tblAccount as a Inner Join tblOrder as o;

You can change the table name to an alias name from the QBE grid, you don't need to change it in the SQL view.

Sam Summers
10-29-2002, 01:29 PM
Thank you very much for that it worked which is brilliant !!!

Part of my problems are due to trying to minimise the amount of tables I am using hence the Level applies to a few certificates as well as the IRATA certificate.

What is happening now however is that multiple occurences of the same person are being displayed if the user only selects one search option from the comboboxes.
For example if I have two inductions with different companies and just select the IRATA Level option, I appear twice in the results of the search.
Is there a way of stopping this from happening or do I just have to ensure that the users select two search parameters ?