Access 2007: Can this query be created using "Query By Example"?

210 views Asked by At

I'm sure this I can write this in VBA, but the question is: can I do this in Access 2007's Query By Example? Those who will maintain my work are more familiar with Query By Example than VBA.

Requirements:

I have two tables, a header table and a detail table

Table: Header 
  Field: HeaderID - Primary Key

Table: Detail 
  Field DetailID - Primary Key
  Field HeaderID - Foreign Key
  Field Property (string)
  Field PropertyDescription (string)

Output Requirement: The requirement is to output the data to an Excel Spreadsheet in the following format: A single row per Header is required.

Column 1: HeaderID
Column 2: Property1
Column 3: PropertyDescription1
Column 4: Property2
Column 5: PropertyDescription2
(and so on... Two columns for each Detail record)

Constraints: There are between 1 and 19 detail records for every header record. Therefore, there will be between 3 and 39 non-blank columns in each row.

I have tried using Cross-Tab queries, but I can't quite get the cross-tab query to fit this requirement.

Thanks!

1

There are 1 answers

0
Fionnuala On

I reckon you would need two crosstab queries to do this in QBE. The two crosstabs, one for descriptions and one for properties, could then be joined on the ID and the various columns could be selected.