N
Niklas Östergren
Hi!
I´m using a pretty large but farly straight forward SELECT quiery as a
recordsource for my main form and until reasentöy have this been working
without any problem.
Today I have tryed to populate my application with the old data that we have
in our old db (apr. 1200 records in one table, 1500 in another and so on).
Not a lot of records as you can see but enough to give me problem with
prestanda of this quiery (see below).
In this quiery I have an expression (see below):
DMax("[MemberShipEndDate]";"tblMemberValidation";"[tblMemberValidation].[fkMemberID]
= " & [MemberID] & " AND [MemberShipEndDate] >= Date()")
If I remove this expression in the quiery then it runs fast as it should.
But I need this so my Q is:
- Can I do this in another faster way so the query run´s the way it should?
Her´s the complete query (qryValidMemberShip):
==============================================================
SELECT qryAllPerson.PersonID, qryAllPerson.FirstName, qryAllPerson.LastName,
qryAllPerson.NickName, qryAllPerson.DoB, qryAllPerson.SocialSecurityNo,
qryAllPerson.Sex, qryAllPerson.OwnAddress, qryAllPerson.[C/OPerson],
qryAllPerson.Street, qryAllPerson.fkZipCode, qryAllPerson.WebAddress,
qryAllPerson.Department, qryAllPerson.Attendance, qryAllPerson.PersonNote,
qryAllPerson.[Select], qryAllPerson.City, qryAllPerson.Country,
qryAllPerson.LastUpDated, tblMemberValidation.MemberValidID,
tblMemberValidation.fkMemberID, tblMemberValidation.EntryFeePayed,
tblMemberValidation.VerNo, tblMemberValidation.MemberShipStartDate,
tblMemberValidation.MemberShipEndDate, tblLookUpMemberShipType.MemberType,
tblMemberValidation.SMCMember, tblMember.MemberID, tblMember.MemberNo,
tblMember.MemberCardSent, qryAllPerson.fkNewMemberShipEntryID,
tblMemberValidation.fkMemberShipTypeID
FROM tblMember RIGHT JOIN (tblLookUpMemberShipType RIGHT JOIN (qryAllPerson
RIGHT JOIN tblMemberValidation ON qryAllPerson.PersonID =
tblMemberValidation.fkPersonID) ON tblLookUpMemberShipType.MemberShipTypeID
= tblMemberValidation.fkMemberShipTypeID) ON tblMember.MemberID =
tblMemberValidation.fkMemberID
WHERE
(((tblMemberValidation.MemberShipEndDate)=DMax("[MemberShipEndDate]","tblMemberValidation","[tblMemberValidation].[fkMemberID]
= " & [MemberID] & " AND [MemberShipEndDate] >= Date()")));
=================================================================
And her´s the complete quiery of (qryAllPerson):
===============================================================
SELECT tblPerson.PersonID, tblPerson.LastName, tblPerson.FirstName,
tblPerson.NickName, tblPerson.DoB, tblPerson.SocialSecurityNo,
tblPerson.Sex, tblPersonAddress.OwnAddress, tblPersonAddress.[C/OPerson],
tblPersonAddress.Street, tblPersonAddress.fkZipCode, tblLookUpZipCode.City,
tblLookUpZipCode.Country, tblPerson.WebAddress, tblPerson.Department,
tblPerson.Attendance, tblPerson.PersonNote, tblPerson.LastUpDated,
tblPerson.[Select], tblPersonFile.FileID, tblPersonFile.Active,
tblPerson.fkNewMemberShipEntryID
FROM ((tblLookUpZipCode RIGHT JOIN tblPersonAddress ON
tblLookUpZipCode.ZipCode = tblPersonAddress.fkZipCode) RIGHT JOIN tblPerson
ON tblPersonAddress.PersonAddressID = tblPerson.fkPersonAddressID) LEFT JOIN
tblPersonFile ON tblPerson.PersonID = tblPersonFile.fkPersonID
WHERE (((tblPersonFile.Active) Is Null Or (tblPersonFile.Active)=0))
ORDER BY tblPerson.LastName, tblPerson.FirstName;
==============================================================
I´m not wery good at SQL so I´l realy need help here!
TIA
// Niklas
I´m using a pretty large but farly straight forward SELECT quiery as a
recordsource for my main form and until reasentöy have this been working
without any problem.
Today I have tryed to populate my application with the old data that we have
in our old db (apr. 1200 records in one table, 1500 in another and so on).
Not a lot of records as you can see but enough to give me problem with
prestanda of this quiery (see below).
In this quiery I have an expression (see below):
DMax("[MemberShipEndDate]";"tblMemberValidation";"[tblMemberValidation].[fkMemberID]
= " & [MemberID] & " AND [MemberShipEndDate] >= Date()")
If I remove this expression in the quiery then it runs fast as it should.
But I need this so my Q is:
- Can I do this in another faster way so the query run´s the way it should?
Her´s the complete query (qryValidMemberShip):
==============================================================
SELECT qryAllPerson.PersonID, qryAllPerson.FirstName, qryAllPerson.LastName,
qryAllPerson.NickName, qryAllPerson.DoB, qryAllPerson.SocialSecurityNo,
qryAllPerson.Sex, qryAllPerson.OwnAddress, qryAllPerson.[C/OPerson],
qryAllPerson.Street, qryAllPerson.fkZipCode, qryAllPerson.WebAddress,
qryAllPerson.Department, qryAllPerson.Attendance, qryAllPerson.PersonNote,
qryAllPerson.[Select], qryAllPerson.City, qryAllPerson.Country,
qryAllPerson.LastUpDated, tblMemberValidation.MemberValidID,
tblMemberValidation.fkMemberID, tblMemberValidation.EntryFeePayed,
tblMemberValidation.VerNo, tblMemberValidation.MemberShipStartDate,
tblMemberValidation.MemberShipEndDate, tblLookUpMemberShipType.MemberType,
tblMemberValidation.SMCMember, tblMember.MemberID, tblMember.MemberNo,
tblMember.MemberCardSent, qryAllPerson.fkNewMemberShipEntryID,
tblMemberValidation.fkMemberShipTypeID
FROM tblMember RIGHT JOIN (tblLookUpMemberShipType RIGHT JOIN (qryAllPerson
RIGHT JOIN tblMemberValidation ON qryAllPerson.PersonID =
tblMemberValidation.fkPersonID) ON tblLookUpMemberShipType.MemberShipTypeID
= tblMemberValidation.fkMemberShipTypeID) ON tblMember.MemberID =
tblMemberValidation.fkMemberID
WHERE
(((tblMemberValidation.MemberShipEndDate)=DMax("[MemberShipEndDate]","tblMemberValidation","[tblMemberValidation].[fkMemberID]
= " & [MemberID] & " AND [MemberShipEndDate] >= Date()")));
=================================================================
And her´s the complete quiery of (qryAllPerson):
===============================================================
SELECT tblPerson.PersonID, tblPerson.LastName, tblPerson.FirstName,
tblPerson.NickName, tblPerson.DoB, tblPerson.SocialSecurityNo,
tblPerson.Sex, tblPersonAddress.OwnAddress, tblPersonAddress.[C/OPerson],
tblPersonAddress.Street, tblPersonAddress.fkZipCode, tblLookUpZipCode.City,
tblLookUpZipCode.Country, tblPerson.WebAddress, tblPerson.Department,
tblPerson.Attendance, tblPerson.PersonNote, tblPerson.LastUpDated,
tblPerson.[Select], tblPersonFile.FileID, tblPersonFile.Active,
tblPerson.fkNewMemberShipEntryID
FROM ((tblLookUpZipCode RIGHT JOIN tblPersonAddress ON
tblLookUpZipCode.ZipCode = tblPersonAddress.fkZipCode) RIGHT JOIN tblPerson
ON tblPersonAddress.PersonAddressID = tblPerson.fkPersonAddressID) LEFT JOIN
tblPersonFile ON tblPerson.PersonID = tblPersonFile.fkPersonID
WHERE (((tblPersonFile.Active) Is Null Or (tblPersonFile.Active)=0))
ORDER BY tblPerson.LastName, tblPerson.FirstName;
==============================================================
I´m not wery good at SQL so I´l realy need help here!
TIA
// Niklas