|
|
|
| У меня есть форма в виде таблицы....На основе данных для этой формы сделан отчет. Я произвошу сортировку по различным полям этой формы. Например: отсортировал по Полю_1 и хочу чтобы при выводе отчета данные были отсортированы с такими же параметрами как и в форме...Как передать их (параметры сортировки) из формы в отчет? | |
|
| |
|
|
|
| Неужели никто не знает??? | |
|
| |
|
|
|
| Сортировка в отчета задается в свойстве GroupLevel
вот цитата:
You can use the GroupLevel property in Visual Basic to refer to the group level you are grouping or sorting on in a report. Read-only GroupLevel object.
expression.GroupLevel(Index)
expression Required. An expression that returns one of the objects in the Applies To list.
Index Required Long. The group level, starting with 0. The first field or expression you group on is group level 0, the second is group level 1, and so on.
Remarks
The GroupLevel property setting is an array in which each entry identifies a group level. You can have up to 10 group levels (0 to 9).
The following sample settings show how you use the GroupLevel property to refer to a group level.
Group level Refers to
GroupLevel(0) The first field or expression you sort or group on.
GroupLevel(1) The second field or expression you sort or group on.
GroupLevel(2) The third field or expression you sort or group on.
Note You can use this property only by using Visual Basic to set the SortOrder, GroupOn, GroupInterval, KeepTogether, and ControlSource properties. You set these properties in the Open event procedure of a report.
In reports, you can group or sort on more than one field or expression. Each field or expression you group or sort on is a group level.
You specify the fields and expressions to sort and group on by using the CreateGroupLevel method.
If a group is already defined for a report (the GroupLevel property is set to 0), then you can use the ControlSource property to change the group level in the report's Open event procedure.
Example
The following code changes the ControlSource property to a value contained in the txtPromptYou text box on the open form named SortForm:
Private Sub Report_Open(Cancel As Integer)
Me.GroupLevel(0).ControlSource _
= Forms!SortForm!txtPromptYou
End Sub
|
| |
|
| |
|
|
|
| Если отчёт открывается по кнопке на форме то я бы так сделал
Dim rpt As Report
DoCmd.OpenReport "rptExportForPrintLetters", acViewPreview
Set rpt = Reports!rptExportForPrintLetters
rpt.OrderByOn = False
rpt.OrderBy = Me.OrderBy
rpt.OrderByOn = True
|
Если отчёт открывается не из формы, то в Report_Open надо проверить загружена ли нужная форма и точно также присвоить отчёту
Me.OrderBy = Forms!Форма.OrderBy
|
| |
|
| |