New member here, impressed with what I have searched so far...
So every day data will be imported into a table named the month (ie - 10_2011)... however, this data WILL contain duplicates which I need to get rid of. I am breaking the data up into daily imports into monthly tables because each day the data are over 500-700 rows, wanted to keep tables of manageable size. I'm not married to using this logic, so if someone has a better idea, please share!
I have used snippets of code I found here but I can't seem to make it work... Please if someone could help me, that would be great. I'm not a board certified programmer but I do know enough to break stuff!
So every day data will be imported into a table named the month (ie - 10_2011)... however, this data WILL contain duplicates which I need to get rid of. I am breaking the data up into daily imports into monthly tables because each day the data are over 500-700 rows, wanted to keep tables of manageable size. I'm not married to using this logic, so if someone has a better idea, please share!
I have used snippets of code I found here but I can't seem to make it work... Please if someone could help me, that would be great. I'm not a board certified programmer but I do know enough to break stuff!
Code:
Private Sub cmdImport_Click()
Dim strDay As String
Dim strMonth As String
Dim strFilePath As String
Dim xlobj
Dim wsobj
Dim rngobj
Dim strDataRange As String
strDay = Format(Now(), "mm" & "." & "dd" & "." & "yyyy")
strMonth = Format(Now(), "mm" & "_" & "yyyy")
strFilePath = "<hidden>" & strDay & ".xls"
Set xlobj = GetObject(strFilePath)
Set wsobj = xlobj.worksheets("Sheet1")
Set rngobj = wsobj.usedrange
rngobj.Name = srtDataRange
DoCmd.SetWarnings False
DoCmd.TransferSpreadsheet acImport, 8, strMonth, _
strFilePath, True, strDataRange
DoCmd.SetWarnings True
Set xlobj = Nothing
'routine for deleting Dups created EVERY DAY when excel is imported
Dim db As DAO.Database
Dim rs As Recordset
Dim strAccount As String
Set db = CurrentDb
Set rs = db.OpenRecordset(strMonth)
StartFile:
rs.MoveFirst
Do Until rs!Temp = False
If Not rs.EOF Then
rs.MoveNext
Else
GoTo EndFile
End If
Loop
strEmail = rs!Account_No
rs!Temp = True
rs.MoveNext
Do Until rs.EOF
If rs!Account_No = strAccount Then
rs.Delete
End If
rs.MoveNext
Loop
GoTo StartFile
EndFile:
'remove temp field from table
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Comment