
Code to Copy Records to a New Database
I need some help or guidance all would be appreciated.
I am working with a large table. Approx 100,000 records. I am trying to
make code which will create a new database structure and create a table in
this new structure containing records associated with a particular month.
I have the code to create the new table. My question is what is the best
way to make copy these records. I see too possible solutions. 1. copy the
table entirely and delete other records out. 2. Make a make table query
to copy the records. I have tried the code below and it errors and tells me
that I must have one input field.
Help I am pulling out all my hair trying to overcome this one.
Pete
Public Sub TestExportAFISTransToMonthly()
'
' Export Trans Master to Newly Created DB for Date Range Selected
'
Dim db As DATABASE, strSQL As String
Set db = CurrentDb
Dim ExPath, ExName, ExFile, Target As String
Dim ExBDate, ExEDate As Date
ExBDate = 11 / 1 / 98 'Me!BeginDate
ExEDate = 11 / 30 / 98 'Me!EndDate
ExPath = "C:\AFIS Download" 'Me!DatabasePath
ExName = "Test1.mdb" 'Me!DatabaseName
ExFile = "Nov1998" 'Me!FileIndicator
Target = ExPath & "\" & ExName
ExFile = "AFISTransactionsMaster" & " " & ExFile
strSQL = "SELECT AFISTransactionsMaster.* INTO " & ExFile & " IN '" &
Target & "'" _
& " FROM AFISTransactionsMaster" _
& " WHERE (((AFISTransactionsMaster.Date) Between #11/1/98# And
#11/30/98#)); "
db.Execute strSQL
End Sub