Results 1 to 5 of 5
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    dlookup - exclude a particular option

    I have a query that searches for all line items before a certain date. I use that in a report that is grouped by invoice number. I then use an unbound field and dsum to add up the values for a particular code. This all works fine for my users.

    However, my users want to also see the customer associated with that invoice. The problem is that these are third party invoices and some is paid by my company and some by my customer. If I use dlookup it will only give me , i believe the first one. Sometimes the customer will be the first line item and sometimes my company will be.



    I need a way to look up the name other than my company UNLESS my company is the only name on that invoice.

    Is this possible with a dlookup or will i need to rebuild this whole report some other way?

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    So is there one field that will either list your company name or a customer name? Can you give a sample of your data and another of how you want it to appear.

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Create a query that contains the customers where it is NOT your company. Then left join that query to your report record source and have an IIf statement which states that if the customer from this new query is null then use your company, otherwise use the customer.

  4. #4
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    data is like this
    invoice responsibilitycode customer amount
    a232 1 us 25
    a232 6 company1 30
    c334 1 us 54
    c334 6 company2 85
    c334 6 company2 50
    d223 1 us 45

    Data is like that with a few other fields
    The report my users want is:
    InvoiceNumber OurCost TheirCost TheirCompanyName TotalInvoice

    I have tried to do a query with a left join but it ends up creating duplicates of a bunch of the records and the totals are way off.
    You can see from the sample data there are three scenarios for payment.
    1. All us
    2. All them
    3. Split between the two

    I have done a dsum to get the amounts =Sum(IIf([UpdatedResponsibilityCode]=1,[NetCharge],0))

    However, I cant get their company name to show up consistently because dlookup just picks one of them and since the single line is a summary of the lines the summary just picks one too.

    The query idea seems like it may be on the right track but I am probably just doing it wrong.

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The query will produce these results:
    a232 company1
    c334 company2

    Now when you left join this query in with the main one, joining on invoice, at times invoice will be null such as d223. This should not affect anything that your query already does as it is only interested in the company name.

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

Similar Threads

  1. Replies: 36
    Last Post: 09-22-2016, 06:22 AM
  2. Exclude when the current month is the month to exclude?
    By aellistechsupport in forum Queries
    Replies: 15
    Last Post: 05-16-2015, 09:49 PM
  3. Replies: 4
    Last Post: 10-03-2014, 06:36 AM
  4. Combo Box Wizard does not have option form option
    By CementCarver in forum Forms
    Replies: 5
    Last Post: 02-28-2013, 08:54 PM
  5. no option to import xls file or option all files
    By captgnvr in forum Import/Export Data
    Replies: 3
    Last Post: 09-22-2009, 10:19 AM

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