Results 1 to 6 of 6
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Quick DLookUp question


    I know that I can use DLookUp to find an order number (SO_DOC_NUM) from our sales table (SALES_SO) for a specific customer code on a specific day. What if there are multiple tickets for that customer on that day. How can I pull the first one written that day? SO_DOC_NUM is a number field and they are sequential.

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    India
    Posts
    616
    SO_DOC_NUM is a number field and they are sequential
    To retrieve the first one on that day, first you need to find the minimum of SO_DOC_NUM on a particular date and then use it in your criteria for dlookup.
    Like DLookup("LookupField","TableName","[SO_DOC_NUM]=" & DMin("SO_DOC_NUM","TableName","[DateField]=#" & [SpecificDate] & "# AND [CustomerCode]=" & [SelectedCustomer])
    Does it helps ?

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Ah that makes sense. Haven't tried the DMin function yet. I'll give it a try when I get back to my desk. Appreciate it!

  4. #4
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    So that worked. Except I forgot about something. I'm not sure if this is possible with out building a bunch of other queries.

    SALES_SO is linked to a table called SALES_SO_LN

    SALES_SO has the customers info, the sales number, and the comments. SALES_SO_LN shows all of the items that the customer bought. The 2 tables are linked by the field SO_DOC_NUM.

    Back my original question:

    I want to pull the first ticket written of the designated day, for the designated customer, where there is a certain SKU in the SALES_SO_LN table.

    For example:

    Jim has 3 tickets (1,4,5) on 2/17/14 and 1 ticket (3) on 2/18/14. Tickets 4 and 5 from 2/17 and ticket 3 from 2/18 have the extended warranty SKU on them, but ticket 1 from 2/17 does NOT. I want my expression to find the first ticket written on 2/17 that has the extended warranty SKU, which would be ticket 4 from 2/17.

    Make sense?

  5. #5
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    BTW, I am aware that I can do all of this with queries and no special functions (such as DMin and DLookUp) but even looking at a 1 week period, it goes SO slow. Like 10-15 minutes.

  6. #6
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Actually scratch this thread. I figured out a smoother way of doing via another table I have access to.

    Sorry for wasting anyone's time!

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

Similar Threads

  1. Quick Question
    By chivo123 in forum Access
    Replies: 6
    Last Post: 01-24-2012, 09:52 AM
  2. Quick Question!
    By kp123 in forum Access
    Replies: 1
    Last Post: 12-12-2011, 02:21 PM
  3. Quick question for all of those who use Access
    By claytonkeirns in forum Access
    Replies: 1
    Last Post: 09-06-2011, 04:04 PM
  4. Quick Module Question: :)
    By oregoncrete in forum Modules
    Replies: 11
    Last Post: 04-04-2011, 04:42 PM
  5. Quick Question
    By Imgsolutions in forum Access
    Replies: 3
    Last Post: 07-19-2010, 11:22 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