Hi,
Just made my first Union query, and it sems to work OK, but I have a problem, I need to use the name of the table as a field. My current SQL is as follows:
As you can see, I've specifically stated what the field [PSM Name] should be. I would like to do this by referring to the table name instead, as I think the code would be much neater and as I'm adding more tables to the union it could save me time in the long run...
Thanks
Just made my first Union query, and it sems to work OK, but I have a problem, I need to use the name of the table as a field. My current SQL is as follows:
Code:
SELECT [Diana Kent].*,"Diana Kent" AS [PSM Name],[Diana Kent]![Beneficiary Name]+[Diana Kent]![Estate Name (If Applicable)] AS [RefID]
FROM [Diana Kent]
WHERE ((([Diana Kent].[Beneficiary Name]) Is Not Null))
UNION SELECT [Nick Whewell].*,"Nick Whewell" AS [PSM Name],[Nick Whewell]![Beneficiary Name]+[Nick Whewell]![Estate Name (If Applicable)] AS [RefID]
FROM [Nick Whewell]
WHERE ((([Nick Whewell].[Beneficiary Name]) Is Not Null))
UNION SELECT [Nigel Finch].*,"Nigel Finch" AS [PSM Name],[Nigel Finch]![Beneficiary Name]+[Nigel Finch]![Estate Name (If Applicable)] AS [RefID]
FROM [Nigel Finch]
WHERE ((([Nigel Finch].[Beneficiary Name]) Is Not Null));
As you can see, I've specifically stated what the field [PSM Name] should be. I would like to do this by referring to the table name instead, as I think the code would be much neater and as I'm adding more tables to the union it could save me time in the long run...
Thanks