Results 1 to 8 of 8
  1. #1
    Computers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    5

    Question Subquery Access 2010

    Hi,





    I need some help with trying to create a subquery with SQL.


    I need to add a subquery to an existing query which selects all guestID field values for guests from chicago or gary.

    Here is my code:

    SELECT tblGuest.GuestID, tblGuest.GuestLastName, tblGuest.GuestFirstName, tblGuest.City, tblGuest.PhoneFROM tblGuest
    ORDER BY tblGuest.GuestLastName, tblGuest.GuestFirstName
    (SELECT GuestID
    FROM tblGuest
    WHERE City="Chicago" OR "Gary");


    Thanks

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Why a subquery? Why not set the criteria for the city field to "Chicago" or "Gary"?

  3. #3
    Computers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    5
    For this, I am required to practice using a sub query instead of going into design view and changing it from there.

  4. #4
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    So, are you saying that the above code does not work? If you put "Chicago" Or "Gary" under the field City in your qry, it will display those results.

  5. #5
    Computers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    5
    Hi,

    Okay, I will privately send it to you.

    Thanks again.

  6. #6
    Computers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    5
    oops,

    Yes, every time I try to run the code I get an error that says this.
    Click image for larger version. 

Name:	Error.JPG 
Views:	8 
Size:	19.7 KB 
ID:	16299

  7. #7
    Computers is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    5
    Never mind I figured it out.


    Thanks again,
    Bob

  8. #8
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    For those who may be having the same issue, it is a common courtesy in forums to provide a solution when you resolve on your own. Glad you figured it out, however.

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

Similar Threads

  1. Help on Access Subquery
    By cshannon in forum Queries
    Replies: 1
    Last Post: 02-01-2014, 05:40 PM
  2. Replies: 11
    Last Post: 11-08-2013, 06:14 PM
  3. Access WITH subquery
    By johnseito in forum Access
    Replies: 5
    Last Post: 10-15-2013, 08:41 PM
  4. Access SQL Subquery Problem
    By dfenton21 in forum Access
    Replies: 2
    Last Post: 07-26-2011, 07:54 AM
  5. Access Subquery Max Date/Time field
    By ruci1225 in forum Access
    Replies: 1
    Last Post: 04-08-2011, 07:33 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