This code has worked for years in Access 97 and Access 2002. When I run it with Access 2003 and get "Run-time error '2001': You canceled the previous operation."
The dlookup line of code is highlighted in the debugger.
All references are in the same order the only difference being Microsoft Access 11.0 Object Library vs. Microsoft Access 10.0 Object Library.
Does anyone have any suggestions?
Help !!
The dlookup line of code is highlighted in the debugger.
All references are in the same order the only difference being Microsoft Access 11.0 Object Library vs. Microsoft Access 10.0 Object Library.
Does anyone have any suggestions?
Code:
Private Sub ImportCIC_Click()
Dim MatchFoundSwitch As String
Dim DuplicateSSNandEINSwitch As String
Dim x As String
Dim y As String
Dim z As String
Dim fldConsultant_DataSSN As String
Dim tempSSN As String
Dim InitAgencyString As String
Dim myfile
InitAgencyString = "ESC"
' Check to make sure that file is available
myfile = Dir("c:\sc_wotc_import.txt")
If myfile = "" Then
MsgBox "Program can not find C:\sc_wotc_import.txt -- Import canceled!!"
Exit Sub
End If
' import new data
DoCmd.TransferText acImportFixed, "Consultant_Data_Import_Specification", "tblConsultant_Data", "c:\sc_wotc_import.txt", False, ""
Set dbTrackDB = DBEngine.Workspaces(0).Databases(0)
Set rstblConsultant_Data = dbTrackDB.OpenRecordset("tblConsultant_Data", dbOpenTable)
rstblConsultant_Data.MoveFirst
DoCmd.SetWarnings False
Do Until rstblConsultant_Data.EOF
' determine if there is already an Employee record with same transaction ssn and transactionEIN
If Not IsNull(rstblConsultant_Data!SSN) Then
[COLOR=red] y = Nz(DLookup("[ssn]", "Employees", " [SSN] = rstblConsultant_Data!ssn and [EIN] = rstblConsultant_Data!EINFirst2 & rstblConsultant_Data!EINLast7 "))[/color]
If y <> " " Then
' MsgBox "Employee table match found on SSN and EIN"
With rstblConsultant_Data
.Edit
!notes = " Trans SSN and EIN already on Employee table"
.Update
End With
.
.
.
.
.