Well, I've gone through a rather laborious effort of importing objects and recreating those I that wouldn't import. I'm not done by any means, but I have come across a stumbling block I hope you can shed some light on. When clicking on a command button on the main form I received this error.
Here's the full code. I didn't write any of this so I can't shed much light on it. There are other functions that contain the same syntax. Is there a library reference I need to select?
As usual, Thanks in advance.Code:Public Function DeleteDuplicateSigEvent() Dim cmd1 As ADODB.Command Dim cmd2 As ADODB.Command Dim cmd3 As ADODB.Command Dim sSQL As String Dim sSQL1 As String Dim sSQL2 As String Dim sMsg As String Dim dtRD As Date Dim dtSigDt As Date Dim dtSigTm As Date Dim sShift As String Dim sTySig As String Dim sPatLN As String Dim sPatFN As String Dim sWd As String Dim sZeroShift As String Dim sOneShift As String Dim sTwoShift As String Dim sThreeShift As String Dim iCnt As Integer Dim iCnt1 As Integer Dim iCnt2 As Integer Dim bDupSig As Boolean Dim rsN As ADODB.Recordset Dim rsEmp As ADODB.Recordset ' DoCmd.Hourglass True sZeroShift = "0" sOneShift = "1" sTwoShift = "2" sThreeShift = "3" Set cmd1 = New ADODB.Command cmd1.ActiveConnection = CurrentProject.Connection cmd1.CommandType = adCmdText sSQL = "SELECT * FROM NewSigEvent WHERE Shift ='" & sZeroShift & "';" cmd1.CommandText = sSQL cmd1.Execute Set rsN = New ADODB.Recordset rsN.CursorType = adOpenDynamic rsN.LockType = adLockOptimistic rsN.Open cmd1 iCnt = rsN.RecordCount If iCnt > 0 Then rsN.MoveFirst Do While Not rsN.EOF bDupSig = False dtSigDt = rsN.Fields("SigDate").Value dtSigTm = rsN.Fields("SigTime").Value sTySig = rsN.Fields("TypeSigEvent").Value sPatLN = rsN.Fields("PatLName").Value sPatFN = rsN.Fields("PatFName").Value Set cmd2 = New ADODB.Command cmd2.ActiveConnection = CurrentProject.Connection cmd2.CommandType = adCmdText sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sOneShift & "';" cmd2.CommandText = sSQL cmd2.Execute Set rsEmp = New ADODB.Recordset rsEmp.CursorType = adOpenDynamic rsEmp.LockType = adLockOptimistic rsEmp.Open cmd2 iCnt = rsEmp.RecordCount If iCnt > 0 Then bDupSig = True End If rsEmp.Close Set rsEmp = Nothing Set cmd2 = Nothing Set cmd2 = New ADODB.Command cmd2.ActiveConnection = CurrentProject.Connection cmd2.CommandType = adCmdText sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sTwoShift & "';" cmd2.CommandText = sSQL cmd2.Execute Set rsEmp = New ADODB.Recordset rsEmp.CursorType = adOpenDynamic rsEmp.LockType = adLockOptimistic rsEmp.Open cmd2 iCnt = rsEmp.RecordCount If iCnt > 0 Then bDupSig = True End If rsEmp.Close Set rsEmp = Nothing Set cmd2 = Nothing Set cmd2 = New ADODB.Command cmd2.ActiveConnection = CurrentProject.Connection cmd2.CommandType = adCmdText sSQL = "SELECT * FROM NewSigEvent WHERE SigDate ='" & dtSigDt & "'" & "AND SigTime ='" & dtSigTm & "'" & "AND PatLName ='" & sPatLN & "'" & "AND PatFName ='" & sPatFN & "'" & "AND TypeSigEvent ='" & sTySig & "'" & "AND Shift ='" & sThreeShift & "';" cmd2.CommandText = sSQL cmd2.Execute Set rsEmp = New ADODB.Recordset rsEmp.CursorType = adOpenDynamic rsEmp.LockType = adLockOptimistic rsEmp.Open cmd2 iCnt = rsEmp.RecordCount If iCnt > 0 Then bDupSig = True End If rsEmp.Close Set rsEmp = Nothing Set cmd2 = Nothing If bDupSig = True Then rsN.Delete End If rsN.MoveNext Loop End If DoCmd.Hourglass False rsN.Close Set rsN = Nothing Set cmd1 = Nothing End Function
Paul