Results 1 to 2 of 2
  1. #1
    deemat is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Apr 2015
    Posts
    4

    Question Combine Dlookup and 'if' statement in a query

    Hello,



    Would appreciate any assistance with this.. I have 2 excel files that need to be washed against the other to get unique sales. File A has all the Sale Ids, Sale Type (this column will usually have a '1' in it) and date of sale and File B has some of the sale IDs and date of sale.

    I need the query to do the following
    1. Look up a sale in file A in file B and if its found then return the Sale Type (from file A)
    2. If the sale is not found in File B and the date of Sale is less than equal to 5 days, count as sale (Put a number one in column), else '0'


    Thank you,

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    build a table and index the fields you dont want repeated.
    import the XL files into this table, it will ignore duplicates.

    1. join file A and B on matching keys, build a query that returns the data you want
    2. build an outer join on A and B and put null in File B field criteria to get the items NOT in B. and
    =iif(DateDiff("d",[SaleDate],date()) <=5, DateDiff("d",[SaleDate],date()), 0)

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

Similar Threads

  1. Dlookup with a function in the where statement
    By nigelbloomy in forum Queries
    Replies: 3
    Last Post: 07-31-2013, 10:07 AM
  2. Replies: 1
    Last Post: 02-26-2013, 01:45 PM
  3. Replace DLookUp() with a SELECT statement?
    By Artist.Anon in forum SQL Server
    Replies: 9
    Last Post: 02-18-2013, 12:31 AM
  4. using the and function in a dlookup statement
    By englisap in forum Programming
    Replies: 10
    Last Post: 01-10-2011, 09:53 PM
  5. Help Using Variable in DLookup Statement
    By bcmarshall in forum Access
    Replies: 9
    Last Post: 12-02-2010, 12:44 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