Hey there--
I have a form with two listboxes, each populated by SQL statements that pull from separate tables, like this:
lstAvail.RowSource = SELECT Person_Id, LastName, FirstName FROM HREmps WHERE Person_Id NOT IN (SELECT Person_Id FROM Employees) ORDER BY LastName, FirstName;
lstSel.RowSource = SELECT Person_Id, cLName, cFName FROM Employees ORDER BY cLName, cFName, Person_Id;
This shows all employees in the Employees table (in lstSel) and only those employees in the HREmps table that are not already in Employees (in lstAvail).
The problem is that opening the form takes around 2mins, as does requerying the recordset when a record is copied from HREmps to Employees. I'm assuming this is because Access, in its infinite wisdom, runs the subquery for every record in the HREmps table (about 1900) to compare Person_Id.
I'm wondering if anyone has some thoughts about how to speed this up? Is something wrong with my SQL? Could there be an easier way to do this?
Thanks
4 5254
Are the tables [HREmps] and [Employees] in one-to-one relation by [Person_ID]? Or in one-to-many?
Hey there--
I have a form with two listboxes, each populated by SQL statements that pull from separate tables, like this:
lstAvail.RowSource = SELECT Person_Id, LastName, FirstName FROM HREmps WHERE Person_Id NOT IN (SELECT Person_Id FROM Employees) ORDER BY LastName, FirstName;
lstSel.RowSource = SELECT Person_Id, cLName, cFName FROM Employees ORDER BY cLName, cFName, Person_Id;
This shows all employees in the Employees table (in lstSel) and only those employees in the HREmps table that are not already in Employees (in lstAvail).
The problem is that opening the form takes around 2mins, as does requerying the recordset when a record is copied from HREmps to Employees. I'm assuming this is because Access, in its infinite wisdom, runs the subquery for every record in the HREmps table (about 1900) to compare Person_Id.
I'm wondering if anyone has some thoughts about how to speed this up? Is something wrong with my SQL? Could there be an easier way to do this?
Thanks
you can try this option. Its an unmatched query -
-
SELECT Person_Id, LastName, FirstName
-
FROM HREmps LEFT JOIN Employees ON [HREmps ].[Person_Id] = [Employees].[Person_Id]
-
WHERE ([HREmps ].[Person_Id] Is Null);
-
-
you can try this option. Its an unmatched query -
-
SELECT Person_Id, LastName, FirstName
-
FROM HREmps LEFT JOIN Employees ON [HREmps ].[Person_Id] = [Employees].[Person_Id]
-
WHERE ([HREmps ].[Person_Id] Is Null);
-
-
There was a typo in the WHERE clause; it should be - WHERE ([Employees].[Person_Id] Is Null);
But that works perfectly! Took the load/requery time from 2mins to 2seconds.
Thanks!
There was a typo in the WHERE clause; it should be - WHERE ([Employees].[Person_Id] Is Null);
But that works perfectly! Took the load/requery time from 2mins to 2seconds.
Thanks!
Excellent...I modeled mine then tried pasting in your field names...guess I missed that one :)
Happy to help.
J
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RCS |
last post by:
I've been running into more and more complexity with an application, because
as time goes on - we need more and more high-level, rolled-up information.
And so I've created views, and views that use...
|
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by...
|
by: stoppal |
last post by:
I need some help.
I am trying to write a query which does the following
SELECT * from table1 where field1=(SELECT distinct field1 FROM table1
WHERE field2='2005' or field2='2010')
|
by: Brian |
last post by:
Hello All -
I am wondering if anyone has any thoughts on which is better from a
performance perspective: a nested Select statement or an Inner Join.
For example, I could do either of the...
|
by: Pavel Stehule |
last post by:
Hello,
Pg make query 1. and 2. very fast (use index), but for query 3. dont use
index. I can solve its using select union, but I readed so pg 7.5 don't
problem with OR operator. I use cvs pg. I...
|
by: frizzle |
last post by:
Hi group.
I have a news management system, with a mySQL backend.
I tested it yesterday with 1.000.000+ records, testing my url system.
I pulled out records calling them by the url field. It was...
|
by: laurentc via AccessMonster.com |
last post by:
Hi.
I have an issue with my Access project.
I have rather big tables of data (about 11 000 rows).
These tables are historical product quotations, so they are very simple :
- MyDate...
|
by: No bother |
last post by:
I am using 5.0.26-NT on Windows 2000.
I have need to use a reference in the outer from clause in a subquery in
the select clause. Consider the following example:
Select (select b.baitID from...
|
by: jordonkraft |
last post by:
Table Structure.
tblData
----------
fldID (AutoNumber) (PK)
fldType (String)
fldLocationID (Number)
tblLocation
---------------
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |