Page 2 of 2 FirstFirst 12
Results 16 to 29 of 29
  1. #16
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Attachment is uploaded please help. its urgent.
    Attached Files Attached Files

  2. #17
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    The expression in the query is not quite the one in your post. Instead of table Subbie_Clean_Data, the db has Table1.

    The expression won't work if there is no data in the Prices table Road_Air field, which is the case for most of the records. And for the records with values, none are "Road" nor "Air". So of course nothing will match and the DLookup returns nothing. Example:

    4 records in Table1 for RouteNo 526, 2 for Air and 2 for Road all for size 0.24, however, there is only one record in Prices for Route 526 Size 0.24 and does not have value in the Road_Air field. I put Air into the field and now Price value for 2 records shows in the query.

    Bad data means bad results.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Hi June

    Thank you for your help

    I am using the below query, and it is not displaying correct data,
    Price: DLookUp(Format([SvcDate],"mmm"),"Prices_table","Type='" & [Base_Table].[Type] & "' AND [Size]=" & [Base_Table].[Size] & " AND [RouteNo]=" & [Base_Table].[RouteNo] & "")

    Where RouteNo and Size is Number and Type is Text. It does not return any prices though there are prices against them. Also I have this scenario where I have 3 same routes and sizes are different, it should display price against that route and that size, it is not performing a vlookup against that row. please help.

  4. #19
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Is that using the dataset in the posted db?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Yes its the same, the only thing is if there is even one column missing it would not pick up the price. I am attaching the current db.
    Attached Files Attached Files

  6. #21
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    The Road_Air field in BNE_Subbie_Prices_Table still has no values for "Road" or "Air". No price data can be retrieved. Put "Road" and "Air" values into the table and the query works.

    However, there is no reason to include BNE_Subbie_Prices_Table in the query.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #22
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Quote Originally Posted by June7 View Post
    The Road_Air field in BNE_Subbie_Prices_Table still has no values for "Road" or "Air". No price data can be retrieved. Put "Road" and "Air" values into the table and the query works.

    However, there is no reason to include BNE_Subbie_Prices_Table in the query.


    ==============
    Hi June

    I have written few queries. but the result is not coming out. It just gives me just 0 values for both routeno and size, the dataset is the same.

    Price3 : Dlookup(Format([SvcDate]), "Prices_Table", "[routeno]= " & [Table_Name].[routeno] &" And [size]= " &[tablename].[size] &"")

    The above query just gives me wrong numbers when i execute the above query.

  8. #23
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    Well, I added "Road" or "Air" to Road_Air field in some records in BNE_Subbie_Price_Table and the query works.

    Don't know what else I can tell you.

    Why does the example show Table_Name and tablename?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #24
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,536

  10. #25
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Quote Originally Posted by alansidman View Post

    No the query is still not sorted out.

    I am not getting the desired output when combining 3 conditions in Dlookup.

    Please help.

    Please post your query. I need to see whats wrong with the one I have mentioned on the post.

  11. #26
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Quote Originally Posted by irfanparbatani View Post
    No the query is still not sorted out.

    I am not getting the desired output when combining 3 conditions in Dlookup.

    Please help.

    Please post your query. I need to see whats wrong with the one I have mentioned on the post.
    =====================

    This is the scenario

    I have this table
    Route Type Road_Air JAN FEB MAR APR MAY JUN JUL AUG
    125 Liquid Road 12 12 12 12 12 12 12 12
    125 Metal 13 13 13 13 13 13 13 13
    125 Air 14 14 14 14 14 14 14 14


    If My route no is 125 and Type is Liquid and Road_Air = Road, Display Jan Price
    If my route no is 125 and Type is Metal, then display second priceline i.e Jan = 13
    If my route is 125 and Road_Air = "Air", then display third priceline for Jan = 14
    If my route is 125 and above all criteria doesn't meet, display 4th price for Jan.


    please help me with the above query.

  12. #27
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    There is no Type field in the sample db. There is a Size field. Your query uses Size field. Previous posts all referenced Size field.

    And this need to allow for variation in the number of conditions is new. That really complicates the DLookup.

    Working with the posted db:

    SELECT SvcDate, RouteNo, Size, Road_Air, DLookUp(Format([SvcDate],"mmm"), "[BNE_Subbie_Prices_Table]", "RouteNo='" & [RouteNo] & "' AND Size='" & [Size] & "' AND Road_Air " & IIf(IsNull([Road_Air]), "Is Null", "='" & [Road_Air] & "'")) AS Price
    FROM Table1;
    Last edited by June7; 08-04-2014 at 02:53 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #28
    irfanparbatani is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    17
    Quote Originally Posted by June7 View Post
    There is no Type field in the sample db. There is a Size field. Your query uses Size field. Previous posts all referenced Size field.

    And this need to allow for variation in the number of conditions is new. That really complicates the DLookup.

    Working with the posted db:

    SELECT SvcDate, RouteNo, Size, Road_Air, DLookUp(Format([SvcDate],"mmm"), "[BNE_Subbie_Prices_Table]", "RouteNo='" & [RouteNo] & "' AND Size='" & [Size] & "' AND Road_Air " & IIf(IsNull([Road_Air]), "Is Null", "='" & [Road_Air] & "'")) AS Price
    FROM Table1;
    Thank you for the query. Can you please help with vba.

  14. #29
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,630
    VBA for what? Time for a new thread?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. VLookup
    By chethan1333 in forum Access
    Replies: 1
    Last Post: 02-23-2013, 10:14 AM
  2. Replies: 2
    Last Post: 10-09-2012, 03:20 PM
  3. Vlookup in Access with SQL
    By jogunjobi in forum Queries
    Replies: 1
    Last Post: 01-30-2012, 07:25 PM
  4. converting base 32 to base 10?
    By brandonze in forum Access
    Replies: 13
    Last Post: 08-01-2011, 04:11 PM
  5. Replies: 2
    Last Post: 11-29-2010, 11:16 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