В vba не работает предикат TOP |
Private Sub Ê237;î239;ê224;12_Click() On Error GoTo e Dim S As String Dim ReportRst As DAO.Recordset Dim ReportData As Variant If (IsNull(Me.month1.Value)) Or (IsNull(Me.day1.Value)) Then MsgBox "Не выбран период.", , "Отмена!" Exit Sub End If S = "SELECT TOP 100 Base.CLIENT_ID, Base.CLIENT_NAME, Base.MOBILE_PHONES " S = S & "FROM Base " S = S & "WHERE (((Day(Base.DATE_CREATE))=" & Me.day1.Value & ") And ((month(Base.DATE_CREATE))=" & Me.month1.Value & ")) " S = S & "ORDER BY Base.CLIENT_ID ASC" Set ReportRst = CurrentDb.OpenRecordset(S) If ReportRst.RecordCount > 0 Then ReportData = ReportRst.GetRows(ReportRst.RecordCount) Else MsgBox "Äàííûõ íåò.", , "Äåéñòâèå îòìåíåíî!" Exit Sub End If FillReport ReportData e: Err.Clear End Sub Private Sub FillReport(rData As Variant) Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim i As Integer, j, k As Integer Const LPos = 1, TPos = 1 On Error GoTo e: Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Add(Application.CurrentProject.Path & "\ReportForm.xlsx") Set xlSheet = xlBook.Worksheets(1) xlApp.Visible = False j = 0 Set xlSheet = xlBook.Worksheets(1) xlSheet.Activate With xlSheet .Cells(TPos, LPos + 6).Value = Date End With For k = 0 To UBound(rData, 2) With xlSheet .Cells(TPos + j + 3, LPos + 1).Value = rData(0, k) .Cells(TPos + j + 3, LPos + 2).Value = rData(1, k) .Cells(TPos + j + 3, LPos + 3).Value = rData(2, k) End With j = j + 1 Next k With xlSheet .Cells(TPos, LPos).Select End With xlApp.Visible = True Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing R: Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing Exit Sub e: MsgBox (Err.Description) Err.Clear Resume R End Sub
http://www.sql.ru/forum/1087467/v-vba-ne-rabotaet-predikat-top
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |