Results 1 to 4 of 4
  1. #1
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59

    Query Builder vs SQL Query

    I am havingn issue with QUeries....I am doing UNION query.....



    I have a SQL query that UNIONS a bunch of records to return just those that meet some criteria. Using this query gets the records I want but its a select query and thus the results are NOT EDITABLE.

    If I do a normal query through the wizard I have to set up fields for that will return the values, thus returning extra fields etc...

    HOW CAN I modify the below query (truncated for example) to allow the user to still edit if I point a form to this query?

    SELECT "Art 1" AS Expr1, tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.Master, tbl_V4_Details.Calendar, tbl_V4_Details.Notes
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.StudentID) = 1) AND ((tbl_V4_Details.Calendar) =True) AND ((tbl_V4_Details.LessonNum) = 1))
    ORDER BY tbl_V4_Details.Presented
    UNION
    SELECT "Geography" AS Expr1, tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.Master, tbl_V4_Details.Calendar, tbl_V4_Details.Notes
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.StudentID) = 1) AND ((tbl_V4_Details.Calendar) =True) AND ((tbl_V4_Details.LessonNum) = 2))
    ORDER BY tbl_V4_Details.Presented;


    If I do this I can update the values
    SELECT tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.LessonSubject, tbl_V4_Details.LessonName, tbl_V4_Details.LessonDescription, tbl_V4_Details.Calendar
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.LessonSubject)="Art") AND ((tbl_V4_Details.Calendar)=True))

    If I do this it does NOT allow me too...Seems the SELECT and UNION block this

    SELECT tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.LessonSubject, tbl_V4_Details.LessonName, tbl_V4_Details.LessonDescription, tbl_V4_Details.Calendar
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.LessonSubject)="Art") AND ((tbl_V4_Details.Calendar)=True))
    UNION SELECT tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.LessonSubject, tbl_V4_Details.LessonName, tbl_V4_Details.LessonDescription, tbl_V4_Details.Calendar
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.LessonSubject)="Geography") AND ((tbl_V4_Details.Calendar)=True));

    How can I UNION a bunch of querys together to get one list of values meetign specific qriteria.

    Basically I have one table with a bunch of records...I want only specifc records...the only way I found out how to do thsi was teh UNION query...

    ANY HELP woudl be greatly apprecaited.....

    Thanks

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If this returns the records you want, can you edit this:

    Code:
    SELECT tbl_V4_Details.LessonSubject, tbl_V4_Details.StudentID, tbl_V4_Details.StudentName, tbl_V4_Details.LessonNum, tbl_V4_Details.Master, tbl_V4_Details.Calendar, tbl_V4_Details.Notes
    FROM tbl_V4_Details
    WHERE (((tbl_V4_Details.StudentID) = 1) AND ((tbl_V4_Details.Calendar) = True) AND ((tbl_V4_Details.LessonNum) = 1) OR (tbl_V4_Details.LessonNum) = 2))

  3. #3
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    think I got it....give me a few

    JUST SAW yoru post....yea I think that will work as well.....give me a few to figure this out...

    THANK YOU VERY MUCH for your response...think that will work....Peace

  4. #4
    jaykappy is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2009
    Posts
    59
    ssanfu thanks for your example...that worked great....thanks...

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

Similar Threads

  1. Run Query in Macro Builder
    By chewbears in forum Queries
    Replies: 0
    Last Post: 11-21-2011, 09:18 AM
  2. Need to create a UI dynamic query builder
    By dollylectric in forum Programming
    Replies: 1
    Last Post: 11-16-2011, 02:09 PM
  3. Linked Tables verus Query Builder
    By accessmatt in forum Access
    Replies: 5
    Last Post: 09-06-2011, 04:36 PM
  4. sql query builder and tables
    By benjammin in forum Queries
    Replies: 1
    Last Post: 05-28-2011, 02:11 AM
  5. Code Builder
    By nkenney in forum Forms
    Replies: 3
    Last Post: 11-04-2009, 10:58 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