Results 1 to 8 of 8
  1. #1
    tanyapeila is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    42

    Query not pulling data from all selected records

    This is hard to explain in a post!
    First let me say I am no Access Pro, I am self taught and turn to the Internet for all issues I have.



    I have a database with several tables.

    I am trying to pull a report based off a query.

    The first and most important part of the query is that the record is selected, which is have set by adding a check box to each record, and have queried to pull this field as "true". This has worked in past queries from the same form with great success.

    Now comes the confusing and not working part.

    Of the three shippers (records) I am trying to pull, all three have different "Consignee fields" pulling from a Consignee table. When I pull this query even though all three have different consignees I only want it to pull the address of the first shipper's (record's) consignee for the report it is creating but still pull all three shipper's (records') names.

    I'm sure more information will be need please let me know what you need!

  2. #2
    tanyapeila is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    42

    Need to pull address from first record selected

    SELECT OUTBOUND.[SELECT], OUTBOUND.SHIPPER, OUTBOUND.GBL, OUTBOUND.RDD, OUTBOUND.GROSS, OUTBOUND.CUBE, OUTBOUND.[PCS X OF], OUTBOUND.[TOTAL PCS], OUTBOUND.SCAC, OUTBOUND.REMARKS, OUTBOUND.[CONT#], OUTBOUND.VESSEL, OUTBOUND.VOYAGE, OUTBOUND.TO, OUTBOUND.FROM, OUTBOUND.[SEAL#], OUTBOUND.ETD, OUTBOUND.ETA, OUTBOUND.[CUT OFF], OUTBOUND.SIZE, OUTBOUND.SHIPLINE, OUTBOUND.[ALSO NOTIFY], OUTBOUND.[BK#], OUTBOUND.NET, [INTERNATIONAL CARRIER].[CARRIER NAME], [Copy Of Consignee].ConsigneeName, [CONSIGNEE ADDRESSES].[Address 1], [CONSIGNEE ADDRESSES].[Address 2], [CONSIGNEE ADDRESSES].[Address 3], [CONSIGNEE ADDRESSES].City, [CONSIGNEE ADDRESSES].State, [CONSIGNEE ADDRESSES].Field1, [CONSIGNEE ADDRESSES].PostalCode, [CONSIGNEE ADDRESSES].WorkPhone
    FROM [CONSIGNEE ADDRESSES], (OUTBOUND INNER JOIN [INTERNATIONAL CARRIER] ON OUTBOUND.SCAC = [INTERNATIONAL CARRIER].SCAC) INNER JOIN [Copy Of Consignee] ON (OUTBOUND.TO = [Copy Of Consignee].Country) AND (OUTBOUND.SCAC = [Copy Of Consignee].SCAC)
    WHERE (((OUTBOUND.[SELECT])=True));


    So I currently have three records selected. I want to take the field "Consignee Name" from "Copy of Consignee" table and join it with the Consignee Address table. However all three records have different Consignees and when I add this relationship it only give me one record. I want the query to pull all three records but just the consingee address from the first selected record.

    Does that make sense?

    Click image for larger version. 

Name:	Capture.PNG 
Views:	5 
Size:	37.1 KB 
ID:	15785
    Last edited by tanyapeila; 03-17-2014 at 12:33 PM. Reason: added screen shot

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You probably have the join links set as INNER. Click on each link line to open the relationship dialog and change the join type. What happens?

    Each consignee should show their related address. Making the additional consignees show address of the first would not be easy. What determines which is the 'first'?
    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
    tanyapeila is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    42
    Good question, I'm not sure how to tell it which one is first so what we have found it the order you enter records in Access is the order the print on report. So "first" would be the record with lowest record number.
    Click image for larger version. 

Name:	Capture.PNG 
Views:	3 
Size:	21.5 KB 
ID:	15791

  5. #5
    tanyapeila is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    42
    sorry did not answer the first part of your message. I did change the join links and that seemed to have worked! Now I just have to figure out why it is not pulling the whole address just part of it. But that's another day! Thank you!!!!!!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    So what makes the 3 records associated with each other - an order number, shipping number? Is record number an autonumber field? What are actual field names?
    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. #7
    tanyapeila is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Mar 2014
    Posts
    42
    Well there are several fields that relate them, but I have created a checkbox field and we select the records we want on the report and that is part of the query. There is a container number and a booking number that are the same for all the selected records as well as the TO field.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    You still need to return the 'first' address? An expression using domain aggregates might help. What you need to know is the MailingListID of that record. Is BookingNumber text type?

    Create a query that joins Outbound with Copy of Consignee. Then reference that query:

    SELECT *, DLookup("MailingListID","queryname","RecordID=" & DMin("RecordID","queryname","[BookingNumber]='" & [BookingNumber] & "'")) AS FirstAddress FROM queryname;

    Another approach might be a nested query using TOP N parameter. Review http://allenbrowne.com/subquery-01.html#TopN
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-22-2013, 12:02 AM
  2. Pull Next Record from Table
    By MegSteele in forum Queries
    Replies: 6
    Last Post: 05-02-2013, 12:26 PM
  3. Replies: 1
    Last Post: 11-10-2012, 09:13 AM
  4. Random Record pull
    By Madmax in forum Access
    Replies: 2
    Last Post: 06-28-2011, 08:26 PM
  5. cannot pull the correct record
    By simba in forum Reports
    Replies: 1
    Last Post: 11-30-2010, 10:45 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