MS Access 报告字段值作为标题,其他字段值在 Table 中
MS Access Report Field Value as Heading with Other Field Values Beneath in Table
在 Microsoft Access 报表中,如何将字段的每条记录显示为列标题,并在其下方显示该列记录中其他字段的记录。
我的查询为我提供了以下格式的数据:
| 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 | | |
其中每条记录都会在报告中产生一个新的 'row'。
有人能帮忙吗?
Table 需要一个唯一的记录标识符 - 应该提供自动编号类型的字段,然后考虑以下事项。
查询 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;
查询 2:
TRANSFORM First(Query1.Data) AS FirstOfData
SELECT Query1.ID, Query1.Category
FROM Query1
GROUP BY Query1.ID, Query1.Category
PIVOT Query1.RecID;
为了后代,我通过设置 table 个未绑定标签来解决这个问题。
我为每个标签指定了一个控件名称 x-y,其中 x 是列号,y 是行号。
然后我遍历每一列和每一行,并将标签的标题更改为我的 RecordSet 中的值。
(Form("FormName").Controls.Item(x & "-" & y)).Caption = .Fields("FieldName")
在 Microsoft Access 报表中,如何将字段的每条记录显示为列标题,并在其下方显示该列记录中其他字段的记录。
我的查询为我提供了以下格式的数据:
| 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 | | |
其中每条记录都会在报告中产生一个新的 'row'。
有人能帮忙吗?
Table 需要一个唯一的记录标识符 - 应该提供自动编号类型的字段,然后考虑以下事项。
查询 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;
查询 2:
TRANSFORM First(Query1.Data) AS FirstOfData
SELECT Query1.ID, Query1.Category
FROM Query1
GROUP BY Query1.ID, Query1.Category
PIVOT Query1.RecID;
为了后代,我通过设置 table 个未绑定标签来解决这个问题。
我为每个标签指定了一个控件名称 x-y,其中 x 是列号,y 是行号。
然后我遍历每一列和每一行,并将标签的标题更改为我的 RecordSet 中的值。
(Form("FormName").Controls.Item(x & "-" & y)).Caption = .Fields("FieldName")