Reputation: 93
I have two fields from two different tables that I am doing a union query between in VBA. I just realized that I need another field to be visible in this query called MARKET SEGMENT. I am unsure how to add this in because of the union. Any help would be greatly appreciated.
ImportIDQuery = "SELECT PDFVerified.[FORMULARY ID] FROM PDFVerified " & _
"UNION " & _
"SELECT SearchableVerified.[FORMULARY ID] FROM SearchableVerified"
Upvotes: 2
Views: 4886
Reputation: 35323
like any other field, add a comma and table.field name.
Data type in both tables MUST Be the same... and be placed in the same ORDER within both selects for the union to work... correctly.
ImportIDQuery = "SELECT PDFVerified.[FORMULARY ID], PDFVerified.[Market Segment] FROM PDFVerified " & _
"UNION " & _
"SELECT SearchableVerified.[FORMULARY ID], SearchableVerified.[Market Segment]
FROM SearchableVerified"
Upvotes: 5