Results 1 to 3 of 3
  1. #1
    Abedecain is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    6

    A method other than DLookUp

    Edit, on review this is more of a query issue than anything else!



    Hi, this report has been annoying me and I cant think of a simpler solution to the one I have. It is at the moment taking a awful long time to query as there is 12 DLookUp's for each record.

    Currently I have a Contract starting date and service frequency which dictates when something needs to be serviced, i.e. quaterly.
    In another table that is linked is the maintenance documentation which has the related contract id and date it was done.

    All I need is a x when there is maintenance to be done but not uploaded for that month (give or take a months depending on the frequency), and a y when there is maintenance done and uploaded for that month (give or take a months depending on the frequency).

    Code:
    SELECT Contracts.comp_name, Contracts.equipment, Contracts.type, Contracts.start_date,
    IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,1,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,1,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,1,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Jan2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,2,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,2,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,2,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Feb2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,3,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,3,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,3,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Mar2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,4,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,4,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,4,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Apr2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,5,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,5,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,5,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS May2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,6,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,6,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,6,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Jun2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,7,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,7,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,7,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Jul2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,8,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,8,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,8,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Aug2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,9,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,9,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,9,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Sep2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,10,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,10,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,10,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Oct2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,11,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,11,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,11,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Nov2, IIf([Frequency].[months]<1,"✘",IIf(DateDiff("m",[servicing_start],DateSerial(2012,12,1)) Mod [Frequency].[months]=0,IIf(IsNull(DLookUp("Documents.start","Service Planning Calander Doc Lookup","(Contracts.contract_ID)=" & Contracts.contract_ID & " AND (DateDiff('m',[Documents].[start],DateSerial(2012,12,1))>=-Round([frequency].[months]/4) And DateDiff('m',[Documents].[start],DateSerial(2012,12,1))<=Round([frequency].[months]/4))")),"✘","Y"))) AS Dec2, Contracts.archive, Contracts.frequency_service, Frequency.months, Contracts.void_unit, Contracts.contract_ID
    FROM Frequency INNER JOIN Contracts ON Frequency.[frequency] = Contracts.[frequency_service]
    WHERE (((Contracts.archive)=False) AND ((Contracts.frequency_service)<>"N/A") AND ((Contracts.void_unit)=False));
    The DLookUp relates to:

    Code:
    SELECT Documents.category, Documents.attachments, Documents.start, Frequency.months, o.contract_ID
    FROM Frequency INNER JOIN (Contracts o INNER JOIN Documents ON o.contract_ID = Documents.contract_ID) ON Frequency.frequency = o.frequency_service
    WHERE (((Documents.category)="Maintenance Records") AND ((Frequency.months)>0));
    I would really appreciate any help that can be given as this has been giving me a headache!

    Thanks!


    Edit: Relationship table:
    Click image for larger version. 

Name:	Screen.png 
Views:	18 
Size:	11.9 KB 
ID:	10621
    Last edited by Abedecain; 01-08-2013 at 05:49 AM. Reason: I've added the relationship table

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You might want to start with a statement of what exactly you are trying to do in plain English --- no access, no sql, no forms, no reports.
    Once we have an understanding of What you are trying to do, then suggestions/advice might follow.
    12 DLookups for each record shouts out DESIGN.

    Do you have tables and relationships? Did you Normalize your tables?

    Also, when you show us infomration, please show the whole thing. A piece of a diagram, a query or two out of context do not help convey your issue to the reader (at least in my view).

  3. #3
    Abedecain is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    6
    Quote Originally Posted by orange View Post
    You might want to start with a statement of what exactly you are trying to do in plain English --- no access, no sql, no forms, no reports.
    Thanks for the advise.

    I need a yearly planning calendar with under each month for each contract a X when there is a document to be handed in and a Y when it is.

    When the work is to be completed is to be handed in is calculated by the servicing start and frequency of service and will affect if there will be servicing on any given month.

    When a document is submitted, the date is recorded when the work was completed which should affect the X or Y.

    Quote Originally Posted by orange View Post
    Once we have an understanding of What you are trying to do, then suggestions/advice might follow.
    12 DLookups for each record shouts out DESIGN.
    Do you have tables and relationships? Did you Normalize your tables?

    Yes, as shown in this picture:

    Quote Originally Posted by Abedecain View Post
    Edit: Relationship table:
    Click image for larger version. 

Name:	Screen.png 
Views:	18 
Size:	11.9 KB 
ID:	10621
    Quote Originally Posted by orange View Post
    Also, when you show us infomration, please show the whole thing. A piece of a diagram, a query or two out of context do not help convey your issue to the reader (at least in my view).
    What do you mean by the whole thing? The other tables and report don't influence the result of the query which gives the information to the report?

    Thanks
    Last edited by Abedecain; 01-08-2013 at 09:22 AM. Reason: expanded

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DLookup Customer Ship method
    By burrina in forum Forms
    Replies: 2
    Last Post: 12-17-2012, 09:20 AM
  2. Seek Method
    By worldwidewall in forum Access
    Replies: 2
    Last Post: 03-08-2012, 02:46 PM
  3. Transferspreadsheet Method
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 11
    Last Post: 06-30-2011, 11:40 AM
  4. Class Method
    By AndreT in forum Programming
    Replies: 3
    Last Post: 01-20-2011, 02:18 AM
  5. Which method is better?
    By undrcvr in forum Database Design
    Replies: 3
    Last Post: 05-24-2010, 12:46 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums