Dear all,
I just attended a VBA programming class, but still very very new to VBA codes.
I have one table that consist of two fields (F1, DateAdded)
Field1 DateAdded
--------------------
ABC 1/5/2009 10:30
ABC 1/5/2009 12:30
P/S: The default value of DateAdded has been set as Now()
Trying to import a text file everyday that consist of [field1] data only. I would like the access program to check if duplicate data imported, then whichever earlier (based on DateAdded) will be deleted immediately.
Take for example, in the above case. Only the ABC 1/5/2009 12:30 will be retained in Table. How should I go about it?
The following is the code I used.
I just attended a VBA programming class, but still very very new to VBA codes.
I have one table that consist of two fields (F1, DateAdded)
Field1 DateAdded
--------------------
ABC 1/5/2009 10:30
ABC 1/5/2009 12:30
P/S: The default value of DateAdded has been set as Now()
Trying to import a text file everyday that consist of [field1] data only. I would like the access program to check if duplicate data imported, then whichever earlier (based on DateAdded) will be deleted immediately.
Take for example, in the above case. Only the ABC 1/5/2009 12:30 will be retained in Table. How should I go about it?
The following is the code I used.
Code:
Private Sub Import()
Dim myfile As String
Dim db As Database
Set db = DBEngine(0)(0)
myfile = OpenFile("c:\", "txt", "*.txt", 0)
If myfile = "" Then
End
End If
On Error GoTo ImportPREVV_Err
DoCmd.SetWarnings False
DoCmd.TransferText acImportFixed, "PREVV", "PREVV", "C:\PREVV.txt", False, ""
ImportPREVV_Exit:
Exit Sub
ImportPREVV_Err:
MsgBox Error$
Resume ImportPREVV_Exit
End Sub