Results 1 to 5 of 5
  1. #1
    CodeLiftSleep is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Posts
    48

    Question Weird situation---VBA union SQL Query bringing back fewer records than Created Query Union Query

    I'm not exactly sure what's happening or why it's occurring...



    Background: I have 3 tables on SharePoint linked to the frontend of a Access solution I am building. I then run a Query to Union these tables together because I need to look at all of them as a group and the SQL queries to do this while they were 3 separate tables was getting a little out of hand.

    I am currently running it in the Access open AutoExec Macro via VBA and it brings back 14,765 records. However, if I create a query for it and then run it, the same SQL brings back 15650 records or something around there(it's between 800-1000 records more).

    Anyone know what might be happening here? Does the DoCmd.RunSQL have a limit to how many records it can bring back?

    I'm assuming I can just build a query and have that run upon opening the same way, but I prefer the VBA solution. Any ideas? Do I need to do something special to run it as a created query or just called QueryDefs from VBA?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Could one be bringing UNIQUE values?

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    If the query is just a SELECT, why do you use RunSQL? RunSQL is to execute SQL actions (DELETE, UPDATE, INSERT). Just Open the query or use it in a report.

    Why do you have 3 separate tables? Why not 1 table with another field for a category value?

    Are you sure the two SQL statements are identical?
    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
    CodeLiftSleep is offline Advanced Beginner
    Windows 10 Access 2013 32bit
    Join Date
    May 2017
    Posts
    48
    Quote Originally Posted by June7 View Post
    If the query is just a SELECT, why do you use RunSQL? RunSQL is to execute SQL actions (DELETE, UPDATE, INSERT). Just Open the query or use it in a report.

    Why do you have 3 separate tables? Why not 1 table with another field for a category value?

    Are you sure the two SQL statements are identical?
    I didn't design the SharePoint tables nor do I have the ability to change them. Apparently there are too many items to fit in one table.

    Yes I'm sure, I copy and pasted it into the query designer and ran it.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    "too many items to fit in one table" - too many fields? Sounds like non-normalized data structure.

    You copy/pasted the SQL from VBA?

    Again, I don't understand using RunSQL for a SELECT query. Are you running an INSERT action?

    Post your VBA code.
    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. Convert Union Query to non-union help
    By Ekhart in forum Queries
    Replies: 2
    Last Post: 01-10-2017, 03:39 AM
  2. Replies: 2
    Last Post: 10-16-2015, 10:15 PM
  3. Suming Duplicate Records in Union Query
    By Sqnwk in forum Access
    Replies: 1
    Last Post: 10-30-2012, 06:10 PM
  4. Replies: 8
    Last Post: 10-22-2012, 07:43 PM
  5. Union Query Dropping Records
    By Bedsingar in forum Queries
    Replies: 2
    Last Post: 07-18-2011, 09:29 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