so I have 10k csv files i need to look through. Pretty I have a loop which goes through the list of reports. It imports the csv from a particular file and then does query exports the result back out moves on to the next csv however, because there are 10k csv files the database grows past its maximum 2GB is there a way to refresh the database mid loop to? Something like "Application.SetOption 'Auto compact', True" which works.
Set rs = CurrentDb.OpenRecordset("Select * From NormalReports") 'Table of reports
If Not (rs.EOF And rs.BOF) Then 'This loop goes through each normal directory and creates the winners list for directory.
rs.MoveFirst
Do Until rs.EOF = True
Directory = rs!Directory
ReportName = rs!Name
NUMBDATASTr = Directory & "NUMBDATM.CSV"
NICHDATMSTr = Directory & "NICHDATM.CSV"
PRNTDATMSTr = Directory & "PRNTDATM.CSV"
If Directory Like "E:*" Then
CTRY = "UK"
ElseIf Directory Like "F:*" Then
CTRY = "FR"
ElseIf Directory Like "G:*" Then
CTRY = "PW"
ElseIf Directory Like "H:*" Then
CTRY = "ES"
ElseIf Directory Like "I:*" Then
CTRY = "IT"
ElseIf Directory Like "J:*" Then
CTRY = "AT"
ElseIf Directory Like "K:*" Then
CTRY = "DE"
ElseIf Directory Like "R:*" Then
CTRY = "RU"
ElseIf Directory Like "N:*" Then
CTRY = "NO"
ElseIf Directory Like "C:*" Then
CTRY = "UK"
Else
MsgBox "Invalid directory Found"
Exit Sub
End If
DoCmd.SetWarnings False
DoCmd.OpenQuery "ResetNumbDatM"
DoCmd.OpenQuery "ResetNICHDATM"
DoCmd.OpenQuery "ResetPRNTDATM"
DoCmd.SetWarnings True
'Current Issues data types of the tables conflicting make sure to change that. Issue Noted: 06/07/2018. Resolved: NOT
Dim CombLoop As Integer
Dim LotusCn As Object
Dim rsLotus As Object
Dim strSql, CombFileName, GotoRange As String
Dim rsLotusFiles As DAO.Recordset
Set LotusCn = CreateObject("ADODB.Connection")
Set rsLotus = CreateObject("ADODB.Recordset")
DoCmd.SetWarnings False
DoCmd.TransferText TransferType:=acImportDelim, TableName:="NUMBDATM", FileName:=NUMBDATASTr, HasFieldNames:=True
DoCmd.DeleteObject acTable, "NUMBDATM_ImportErrors"
DoCmd.TransferText TransferType:=acImportDelim, TableName:="PRNTDATM", FileName:=PRNTDATMSTr, HasFieldNames:=True
DoCmd.DeleteObject acTable, "PRNTDATM_ImportErrors"
DoCmd.TransferText TransferType:=acImportDelim, TableName:="NICHDATM", FileName:=NICHDATMSTr, HasFieldNames:=True
DoCmd.DeleteObject acTable, "NICHDATM_ImportErrors"
DoCmd.SetWarnings True
'Save Path for First Export
SaveFile = Directory & "AWD_" & MTH & ".csv"
'End of Save Path First Export
'Display Winners and create the table
DoCmd.SetWarnings False
DoCmd.OpenQuery "AWDWINNERSQRY"
DoCmd.SetWarnings True
'End Display
'Export Winners to their Directory to their individual Directories
db.TableDefs.Refresh
DoCmd.TransferText acExportDelim, , "AWDWinners", SaveFile, True
db.TableDefs.Refresh
'Export to Directory Finished
SaveFile = "Q:\CCNMACS\AWD" & CTRY & "\AWD_" & MTH & ReportName & ".csv"
'Export Winners to their Directory to their individual Directories
db.TableDefs.Refresh
DoCmd.Rename "AWDWinners" & ReportName, acTable, "AWDWinners"
DoCmd.TransferText acExportDelim, , "AWDWinners" & ReportName, SaveFile, True
db.TableDefs.Refresh
'Export to Directory Finished
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "AWDWinners" & ReportName
DoCmd.SetWarnings True
Application.SetOption "Auto compact", True
rs.MoveNext
Loop
Else
MsgBox "There are no Records in the RecordSet."
End If
rs.Close
Set rs = Nothing