2017-08-10 92 views
0

在Microsoft Access报表中,如何将字段的每个记录显示为列标题,并在该列下的其他字段记录中记录下列字段。作为标题的MS Access报表字段值在表012下面的其他字段值的标题

我的查询给我的数据的格式如下:

| ID | Item | Item Characteristic 1 | Item Characteristic 2 | Other Fields | 
|:--:|:------:|:---------------------:|:---------------------:|--------------| 
| 22 | Code 1 |   Blue   |   48   | …   | 
| 22 | Code 2 |   Red   |   50   | …   | 
| 22 | Code 3 |   Green   |   99   | …   | 

我想对我的报告是这个样子:

|  Heading  | Data True to All Records1 | More Data True to All Records2 |    | 
|:---------------------:|:-------------------------:|:------------------------------:|:------------:| 
|  ------------  |  ------------  |   ------------   | ------------ | 
|   Item   |   Code 1   |    Code 2    | Code 3 | 
| Item Characteristic 1 |   Blue   |    Red    |  Green | 
| Item Characteristic 2 |    48   |    50    |  99  | 
|  Other Fields  |    …    |    …    |  …  | 
|  ------------  |  ------------  |   ------------   | ------------ | 
|   Footer  | Data True to All Records3 | More Data True to All Records4 |    | 

目前,我只能得到数据格式为:

| Heading |  | | 
|:-------:|:-----:|:--:| 
| ---- |  | | 
| Code 1 | Blue | 48 | 
|   |  | | 
| Code 2 | Red | 50 | 
|   |  | | 
| Code 3 | Green | 99 | 
| --- |  | | 
| Footer |  | | 

其中每条记录在报告中产生一个新的“行”。

谁能帮助?

回答

0

对于后人,我设置了绑定标签的表解决了这个。

我给每个这些标签的控制名称为x-y,其中x是列号,y是行号。

然后,我循环遍历每一列和行,并将标签的标题更改为我的RecordSet中的值。

(Form("FormName").Controls.Item(x & "-" & y)).Caption = .Fields("FieldName")

0

表需要一个唯一的记录标识符 - 自动编号类型字段应该服务,然后考虑以下内容。

查询1:

SELECT RecID, ID, "Item" AS Category, Item AS Data FROM Tablename 
UNION SELECT RecID, ID, "ItemChar1", ItemChar1 FROM Tablename 
UNION SELECT RecID, ID, "ItemChar2", ItemChar2 FROM Tablename; 

QUERY2:

TRANSFORM First(Query1.Data) AS FirstOfData 
SELECT Query1.ID, Query1.Category 
FROM Query1 
GROUP BY Query1.ID, Query1.Category 
PIVOT Query1.RecID; 
相关问题