Rainbow писал(а):Чего? Что значит "запустить отчет"?
Это вопрос из серии "как запустить ракету, если у меня есть топливо?"
Что ты хочешь увидеть?Ты грид нашел? Ты не знаешь, как показать данные в гриде? Или ты действительно отчетами занялся? термин "отчет" обычно означает документ, постороенный по БД, готовый к печати. Для этих отчетов есть свои инструменты...
DoCmd.Echo False
DoCmd.OpenReport "Отчёт", acViewPreview
DoCmd.PrintOut acPrintAll, , , , 3, 0
DoCmd.Echo True
DoCmd.Close acReport, "Отчёт", acSaveNo
Scuder писал(а):Отправить на печать отчёт:
- Код: Выделить всё
DoCmd.Echo False
DoCmd.OpenReport "Отчёт", acViewPreview
DoCmd.PrintOut acPrintAll, , , , 3, 0
DoCmd.Echo True
DoCmd.Close acReport, "Отчёт", acSaveNo
Dim qdf As QueryDef
Dim query As QueryDef
CurrentDb.QueryDefs.Refresh
For Each qdf In CurrentDb.QueryDefs
If qdf.name = "Запрос" Then
db1.QueryDefs.Delete qdf.name
End If
Next qdf
Set query = CurrentDb.CreateQueryDef("Запрос", strSQL)
DoCmd.Echo False
DoCmd.OpenReport "Отчёт", acViewPreview
DoCmd.PrintOut acPrintAll, , , , 3, 0
DoCmd.Echo True
DoCmd.Close acReport, "Отчёт", acSaveNo
по мойму, как то криво.
Dim sArg As String
sArg = "SELECT * FROM bla-bla-bla"
DoCmd.OpenReport "Отчёт", acViewPreview, , , , sArg
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = Me.OpenArgs
End Sub
Leon_ писал(а):Надо делать такDim sArg As String
sArg = "SELECT * FROM bla-bla-bla"
DoCmd.OpenReport "Отчёт", acViewPreview, , , , sArg
А в самом отчете в обработчике открытияPrivate Sub Report_Open(Cancel As Integer)
Me.RecordSource = Me.OpenArgs
End Sub
PS: пока писал -- опередили
Leon_ писал(а):8)
Свойство OpenArgs надо искать не у метода (у которого его и не может быть), а у отчета. Все так, как я написал в примере. Дерзай!
PS: "Me" -- это ссылка не на метод, а на текущий объект -- форму, отчет.
Public strSQL as string
strSQL = "SELECT * FROM bla-bla-bla"
DoCmd.OpenReport "Отчёт", acViewPreview
Private Sub Report_Open(Cancel As Integer)
Me.RecordSource = strSQL
End Sub
F1 писал(а):The OpenReport method carries out the OpenReport action in Visual Basic.
expression.OpenReport(ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
expression Required. An expression that returns a DoCmd object.
ReportName Required Variant. A string expression that's the valid name of a report in the current database. If you execute Visual Basic code containing the OpenReport method in a library database, Microsoft Access looks for the report with this name, first in the library database, then in the current database.
View Optional AcView. The view to apply to the specified report.
AcView can be one of these AcView constants.
acViewDesign
acViewNormal default Prints the report immediately.
acViewPivotChart Not supported.
acViewPivotTable Not supported.
acViewPreview
FilterName Optional Variant. A string expression that's the valid name of a query in the current database.
WhereCondition Optional Variant. A string expression that's a valid SQL WHERE clause without the word WHERE.
WindowMode Optional AcWindowMode.
AcWindowMode can be one of these AcWindowMode constants.
acDialog
acHidden
acIcon
acWindowNormal default
OpenArgs Optional Variant. Sets the OpenArgs property.
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 0