Results 1 to 5 of 5
  1. #1
    mrlins is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Aug 2017
    Posts
    2

    Access newbie needs your help: building a Query

    Hello experts,

    I'm very new to Access so I reached out to some people with experience but nobody could help me even though they were all sure that Access could solve my problem. I'm hoping that someone in this forum can share some input and send me down the right track.

    What I'm trying to do is to calculate a price for a delivery service based on 3 parameters: origin, destination and weight. Sounds simple, right? Origin is expressed as 'Store number', destination as 'zip code' and weight as 'KG'. However, the zip code must be translated to a 'zone' category based on the distance from the origin/store, and the weight needs to be translated to a weight class (1-50, 51-100 and so on). Both these 'translations' follow a fixed pattern agreed with the delivery company, so it's quite a straight lookup once you know where to look. Finally, the price model for the service is a fixed ladder where each zone has a price for each weight class.

    Example) A 75 kg delivery is sent from store 001 to zip code 12345. Zip code 12345 qualifies as zone 2 from store 001 and the weight 75 KG is within the limits of the 51-100 KG class, which for zone 2 costs EUR 50.

    My problem is that I don't know how to:
    A) have Access lookup the correct zone based on the store number and zip code provided. The same zip code would return different values depending on the origin/store so how can I tell Access where to look?
    B) have Access lookup the correct price based on the zone number and weight. Much like a), the same weight would return different values depending on the zone number...

    Only knowing a little bit of Excel-talk, I would express this as asking Access to do several lookups at once, but I don't know how that can be done and I haven't found any Query tutorials online that covers this...



    I understand that this might be basics to some of you, but really - any help would be most appreciated!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    your tWeights table would have 4 fields:

    [zone],[MinWt], [MaxWt],[price]
    z1, 1, 50, 30
    z2, 51, 100, 50

    in a query, qsWtChrg, bring in 2 tables, tShoppingCartDetail and tWeights
    DO NOT JOIN the tables,
    criteria: where tShoppingCartDetail.ItemWt >= tWeights.MinWt and tShoppingCartDetail.ItemWt <= tWeights.MinWt

    this query is an added charge, as well as qsZoneChrg,
    a table of EVERY zip code possible. Even if they dont exist, fill them in.

    then add all queries in a union query,
    qsShoppingCartChrg
    qsZoneChrg
    qsWtChrg

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Would need a table with every store and zip code combination and the associated zone. A non-normalized matrix might be appropriate for this situation. That means the zip codes would be one field then each store would be a field with the zones under each.

    Similarly for the weight classes and zones with pricing data. Have the weight class represented by 2 fields (BeginWt, EndWt), fields for the zones with pricing under each.

    Expressions with DLookup() domain aggregate function can find the zone and pricing. Use code (VBA or macro - I use only VBA) behind a form if you want to save the price to record.

    Do you want to round weights to integer or should the range be 1-50.99 and round to 2 decimals?
    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.

  4. #4
    mrlins is offline Novice
    Windows 7 32bit Access 2013 32bit
    Join Date
    Aug 2017
    Posts
    2
    Thank you both for that surprisingly quick input! I knew I would get some expert advice if I reached out - thank you very much! Now all that remains is for me to learn enough Access to make it happen
    @June7 - the weight data will have decimals, but the price table does not so the values could be rounded down to integers.

    Wish me luck actually building this!

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    You also have to know the Zipcode of the store and destination in order to get the "approximate" distance.
    I say approximate since zip codes represent an area, where as the store and destination are points. So a store could be on the eastern boundary of a zip code area and the destination on the western boundary of its zip code. The distance could be significantly different than that when a store is on western boundary of its zip code and destination on the eastern boundary ---even though the zip codes are he same in each case.

    I wrote a routine to calculate driving distance between zip codes (using Google maps) that may apply.

    A lot depends on exactly what tables and data are available to you.

    Good luck

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

Similar Threads

  1. Simple YTD query... Access newbie here
    By h0raz0n in forum Queries
    Replies: 4
    Last Post: 08-23-2017, 06:42 PM
  2. Replies: 41
    Last Post: 11-04-2016, 11:09 AM
  3. Access Newbie - Query for Daily Subtotals?
    By malikastor in forum Access
    Replies: 3
    Last Post: 01-09-2012, 09:11 PM
  4. Newbie Help with Access Query
    By MartyMojito in forum Access
    Replies: 1
    Last Post: 03-17-2011, 02:50 PM
  5. Replies: 5
    Last Post: 11-24-2010, 11:46 PM

Tags for this Thread

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