Results 1 to 3 of 3
  1. #1
    bartolini_tt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2016
    Posts
    2

    Recordset from more than one query

    Hi All,



    Can You help me with resolve below case ?

    I'm creating in VBA a recordset from two Queries and I received an error when I try to read first value from the recordset.

    Mentioned statement:

    SQL = "select nr_PL1 as ver1, outstanding_PL1 as ver2, DPD_PL1 as ver3 from table1 where table1.id = " & search & " and nr_PL1 Is Not Null "
    SQL = SQL & "select nr_PL2 as ver1, outstanding_PL2 as ver2, DPD_PL2 as ver3 from table1 where table1.id = " & search & " and nr_PL2 Is Not Null "

    When i try to read first value i receive an error: Syntax error in query expression...

    I'm pretty sure that there is an issue when i try to connect second sql with the first one but i need Your professional opinions.
    How Can I create this recordset from two or more queries.
    PS: Method by using " & _" at the ond of line can't be used because the statement is over 25 lines.

    Many Thanks in advance !.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    you forgot UNION....

    SQL = SQL & "UNION select nr_PL2 as ver1, outstanding_PL2 as ver2, DPD_PL2 as ver3 from table1 where table1.id = " & search & " and nr_PL2 Is Not Null "

  3. #3
    bartolini_tt is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    May 2016
    Posts
    2
    Many Thanks ranman256 !

    All The Best For You

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

Similar Threads

  1. Replies: 6
    Last Post: 12-03-2013, 11:14 PM
  2. db recordset query help
    By elios115 in forum Programming
    Replies: 3
    Last Post: 08-06-2013, 02:41 AM
  3. Replies: 2
    Last Post: 03-08-2012, 12:59 PM
  4. Update Query?? or RecordSet??
    By bbrazeau in forum Queries
    Replies: 2
    Last Post: 01-13-2012, 08:44 AM
  5. Replies: 1
    Last Post: 11-13-2009, 03:03 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