Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34

    Probmen with union query


    I have multiple table with I am joining then with UNION ALL as Union query. But the output data only shows only data from first two tables. Where I am doing wrong. I have selected similar column names of each excel sheet.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Post the attempted query SQL statement for analysis.
    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. #3
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34

    Re: Probmen with union query

    Here it is:

    SELECT table1.[Name], table1.[Number], table1.[Product Detail], table1.[Status], table1.Size, table1.Price
    FROM table1
    UNION ALL
    SELECT table2.[Name], table2.[Number], table2.[Product Detail], table2.[Status], table2.Size, table2.Price
    FROM table2
    UNION ALL SELECT table3.[Name], table3.[Number], table3.[Product Detail], table3.[Status], table3.Size, table3.Price
    FROM table3;
    UNION ALL SELECT table4.[Name], table4.[Number], table4.[Product Detail], table4.[Status], table4.Size, table4.Price
    FROM table4;
    UNION ALL SELECT table5.[Name], table5.[Number], table5.[Product Detail], table5.[Status], table5.Size, table5.Price
    FROM table5;

    Quote Originally Posted by June7 View Post
    Post the attempted query SQL statement for analysis.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    That should work but try:

    SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table1" As Source FROM table1
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table2" FROM table2
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table3" FROM table3;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table4" FROM table4;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table5" FROM table5;


    BTW, should not use reserved words as field names. Name is a reserved word, not sure about Number.
    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. #5
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    Now I want to make a query search form [to find matches in tables] and to display query results in a subform. I also need two button to save or print the query results. This subform part is tuff for me. I will be glad if you can help.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I am not sure you need a form/subform arrangement. Review: http://datapigtechnologies.com/flash...tomfilter.html

    Probably better to use a report for print outpupt. Also review: http://datapigtechnologies.com/flash...mtoreport.html

    I don't use dynamic parameters in queries but it is a simple method with little code involved. My preference is to pass filter criteria to form or report like:

    DoCmd.OpenReport "report name", , , "ID=" & Me.ID
    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
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    Thank you.
    From the union query I have created a new query and in design view of new query I have used parameters in createria.
    And again from this new query I have created a search form. Now as the search form works it shows the result in new query but I want to get the search form results in a report. I am novice and have little knowledge of reports. please help.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Set the report RecordSource property to the parameterized 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.

  9. #9
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    Its not clear if you can give me an example Sir ? I am in learning phase.
    From what I will create the report ? I mean by selecting new query or the search form I will create the report ?
    Thanks again.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Is the form RecordSource a saved Access query object with criteria parameters? Use the same query for the report. Build a report essentially the same way as building a form. This is basic Access functionality. Access Help has guidelines.
    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.

  11. #11
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    In my union query below is the scenerio

    SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table1" As Source FROM table1
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table2" FROM table2
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table3" FROM table3;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table4" FROM table4;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table5" FROM table5;

    I have to open each table time to time for update in excel because each table is in .xlsx format.
    My question is: How can I consider the updates in my access query even when access query form is open ?
    Or do I need to close the access query form and then I have to make the updates?
    Please help me with a solution code for a refresh button in both the cases ?

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why is Excel involved?

    If you edit data in Excel the edits will be passed to Access in the link. The form can be refreshed by clicking Refresh from the ribbon or code:

    Me.Requery
    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. #13
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    OK what is the full refresh button code ? Help me on this.
    Excel is involved because then I can enter data in less time I think.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The code is:

    Me.Requery

    You can put that in the Click event of button on form.

    How can entering data in Excel be faster than entering into Access tables? Build forms as interface with tables.
    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.

  15. #15
    sroy is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2013
    Posts
    34
    This has worked for me as you suggested
    That should work but try:

    SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table1" As Source FROM table1
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table2" FROM table2
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table3" FROM table3;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table4" FROM table4;
    UNION ALL SELECT [Name], [Number], [Product Detail], [Status], Size, Price, "Table5" FROM table5;


    But once I have made a query from unionquery - it is showing only two table data. I have created the query to put search parameters for my table. Please help.

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

Similar Threads

  1. Replies: 8
    Last Post: 10-22-2012, 07:43 PM
  2. Union Query Help
    By pmp in forum Queries
    Replies: 4
    Last Post: 10-28-2011, 06:41 AM
  3. Help with a Union Query
    By Bear in forum Queries
    Replies: 12
    Last Post: 08-14-2011, 05:12 PM
  4. Union Query Help
    By jo15765 in forum Queries
    Replies: 7
    Last Post: 01-06-2011, 05:46 PM
  5. Please help me out with union query
    By radicrains in forum Access
    Replies: 1
    Last Post: 10-29-2010, 01:48 AM

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