Запрос на выборку из Access |
| + запрос |
| Sub One() For i = 0 To Sheets("Создание отчета").ListBox2.ListCount - 1 Call СчитываниеДанных_ACCS(Sheets("Создание отчета").ListBox2.List(i)) Next i End Sub Sub СчитываниеДанных_ACCS(Fil_name As String) Dim cnnConnect As ADODB.Connection Dim rstRecordset As ADODB.Recordset Application.ScreenUpdating = False Application.EnableEvents = False Set cnnConnect = New ADODB.Connection Set rstRecordset = New ADODB.Recordset cnnConnect.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\weekly_report.accdb;Persist Security Info=False;" rstRecordset.Open Source:="SELECT * FROM ACCS as AC WHERE [AC].[Филиал1]=" & Fil_name & "",ActiveConnection:=cnnConnect, CursorType:=adOpenDynamic, LockType:=adLockReadOnly, Options:=adCmdText With Sheets("ACCS").QueryTables.Add( _ Connection:=rstRecordset, _ Destination:=Sheets("ACCS").Range("A1")) .Name = "Активы_выгрузка" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .PreserveColumnInfo = True .Refresh BackgroundQuery:=False End With rstRecordset.Close cnnConnect.Close Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub |
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |