Isaac
Lifelong Learner
- Local time
- Yesterday, 22:19
- Joined
- Mar 14, 2017
- Messages
- 8,738
Ok so this SQL looked fine to me, ansi-sql wise. But Access doesn't like it. MUST I have a "from" clause on the bottom half?? Access says to this "Query input must contain at least one table or query". Sorry, I don't do Union's very often in Access, I guess luckily my data structures are usually good enough to where it doesn't come up.
What is the context? Well, I have a Listbox on a form. In this Listbox, I want to populate Name, Account and Username from another query--qryListPeopleWithUsername. This query is a carefully-curated resultset that's "just perfect" - except for one little flaw. For development and testing purposes, I want to "stack" onto it a few more records - the name, account & username of myself and a few testers/admin folks (which will not come up in that query).
So in a practical sense, I want to do precisely what the obvious intent of that union query is.
Another option, I guess, would be to change the Listbox's Rowsource type to Value List, and add all the values in code. Then I can add whatever I jolly well please. But I'm wanting to do this the simplest way and not reinvent the wheel, any other thoughts?
Code:
select qryListPeopleWithUsername.Name, qryListPeopleWithUsername.Account, qryListPeopleWithUsername.Username from qryListPeopleWithUsername
union all
select 'John Doe' as [Name], 'accountvalue(redacted)' as [Account], 'usernamevalue (redacted)' as [Username]
What is the context? Well, I have a Listbox on a form. In this Listbox, I want to populate Name, Account and Username from another query--qryListPeopleWithUsername. This query is a carefully-curated resultset that's "just perfect" - except for one little flaw. For development and testing purposes, I want to "stack" onto it a few more records - the name, account & username of myself and a few testers/admin folks (which will not come up in that query).
So in a practical sense, I want to do precisely what the obvious intent of that union query is.
Another option, I guess, would be to change the Listbox's Rowsource type to Value List, and add all the values in code. Then I can add whatever I jolly well please. But I'm wanting to do this the simplest way and not reinvent the wheel, any other thoughts?