Combine datos de varias tablas de acceso para producir etiquetas de dirección, prefiriendo el apartado postal a la dirección física

I have an Access 2007 database that has 3 tables, each the same.

Each of these tables is for a different telemarketer to enter leads. It is necessary for there to be multiple tables as each marketer must be treated as a separate entity.

Each of these tables has the following fields relevant to the question:


Nombre de la calle

Now what I need to do is create a query for label printing which will prefer the PO Box to the physical address, if the PO Box is empty it will use the physical.

I then need this to be displayed as


ie AddrLine1 if pobox is filled will be the PO Box number, otherwise it will be the building... and so on.

I have tried Unions and Conditional selects so far but to no avail!

¿Cómo hago esto?

preguntado el 01 de febrero de 12 a las 04:02

1 Respuestas


   t.POBoxNumber As AddrLine1,
   t.POBoxSuburb As AddrLine2,
   t.POBoxCity As AddrLine3,
   t.POBoxPostCode As AddrLine4,
   ""  As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Not Null
   AddressBuilding As AddrLine1,
   AddressStreet As AddrLine2,
   AddressSuburb As AddrLine3,
   AddressCity As AddrLine4,
   AddressPostCode As AddrLine5
FROM TheTable t 
WHERE t.POBoxNumber Is Null

If this is not what you want, please explain why it is not and provide some sample data. Your question is a little vague as it stands.

Respondido 01 Feb 12, 15:02

Yeah that's basically it. The FROM TheTable t line, TheTable should be the name of my table i take it, how would I merge the data from 3 tables together with the same fields? - Ryan Buddicom

You should be able to replace TheTable with a subquery that unions the three tables, or just create a union query for the three tables and use the name of that query for TheTable. - Fionnuala

Excellent, thanks Remou! All working perfectly. Apologies for the vague question as well but I couldn't work out how to briefly explain it. - Ryan Buddicom

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.