Results 1 to 7 of 7
  1. #1
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20

    Combining data from two or more dlookups

    Hey, I am very new to the access VBA. I need to add up the data from three or four queries to make a table in access or excel. Instead of using SQL select queries I found DLookup more convenient. But I dont actually know how to combine the result from two different dlookups and how to get the combined result. Any help?

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try to avoid using DLOOKUP when possible. They can be unreliable, inefficient, and only work for one-to-one matches.
    I would recommend SQL over DLOOKUP, whenever possible.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    ALWAYS use querys. Not dlookup.

  4. #4
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20
    Thank you for your replies. For select queries I cant execute.. runSQL. I guess I need to store the result in a recordset. Like this one


    Dim rs As DAO.Recordset
    Query2 = "SELECT Futures.Date, Futures.PX_SETTLE FROM Futures WHERE (((Futures.Date)>#1/1/2014#));"
    Set rs = CurrentDb.OpenRecordset(Query2)

    I don't know how to see the recordset in access and also dont know how to combine three or four recordset. Any Idea?

    THanks

  5. #5
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Dont run queries in recordset code.
    Create them in the query designer list.

    Combine multiple queries in a UNION query.

  6. #6
    mahmud1180 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Sep 2014
    Posts
    20
    I would like to run them in UNION query but the only problem is that in VBA I cant run that directly esp the SELECT queries. Could you please tell how to do that in VBA?

    THanks

  7. #7
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    How is that possible? Access is made to query. Thats is prime function.

    It does no good to make select queries in code, you cant display them.

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

Similar Threads

  1. Replacing Dlookups for editing and speed?
    By g4tv4life in forum Programming
    Replies: 4
    Last Post: 05-15-2014, 02:58 PM
  2. Replies: 5
    Last Post: 05-17-2013, 01:07 AM
  3. Dlookups with multiple criteria
    By jtolsma in forum Programming
    Replies: 1
    Last Post: 04-03-2012, 04:33 PM
  4. Replies: 3
    Last Post: 10-18-2011, 03:08 PM
  5. Dlookups
    By funkygoorilla in forum Access
    Replies: 12
    Last Post: 09-28-2011, 08:35 PM

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