-2147217904 - Too few parameters. Expected 2

simon4amiee

Registered User.
Local time
Today, 04:04
Joined
Jan 3, 2007
Messages
109
Hi all, Im stumped now, early on in my code which worked for years, now suddenly does not and displays the error

-2147217904 - Too few parameters. Expected 2

I can't seem to get to the bottom of it, is there a way I can find the problem out 1 line at a time or is it obvious from here.



Code:
Public Function OutputEM_CDS_6_2_Net(Optional UseArchive As Boolean = False) As Integer
On Error GoTo Err_OutputEM_CDS_6_2_Net

    Dim rst As New ADODB.Recordset, fld As ADODB.Field, cmd As New ADODB.Command
    Dim intFileNum1 As Integer, intFileNum2 As Integer, intFileNum3 As Integer, intFileNum4 As Integer
    Dim intFileNum5 As Integer, intReturnValue As Integer
    Dim intInnerLoop As Integer
    Dim varOutput As Variant
    Dim stSQL As String, stFieldName As String, stFileNum As String
    Dim stFileName1 As String, stFileName2 As String, stFileName3 As String, stFileName4 As String, stFileName5 As String
    Dim lnNoOfRecs As Long, lnLoopCounter As Long
    Dim varResult As Variant
    Dim dtStartDate As Date

    DoCmd.Hourglass True

    If UseArchive Then
    Else
        stSQL = "SELECT DISTINCT FileNumber FROM tblAEData"
        rst.Open stSQL, ConnectString, adOpenKeyset, adLockReadOnly, adCmdText
        If rst.RecordCount = 0 Then
            MsgBox "Couldn't retrieve a file number from tblAEData. " & _
                vbCrLf & "Please check and correct before proceeding."
            GoTo Exit_OutputEM_CDS_6_2_Net
        ElseIf rst.RecordCount <> 1 Then
            MsgBox "There appear to be multiple file numbers loaded." & _
                vbCrLf & "Please check and correct before proceeding."
            GoTo Exit_OutputEM_CDS_6_2_Net
        Else
            stFileNum = rst(0)
        End If
        If rst.State = adStateOpen Then rst.Close

        stSQL = "SELECT Allocate FROM dbo.ImportLog WHERE FileNumber = '" & stFileNum & "' And ActivityType = 'AE'"
        rst.Open stSQL, ConnectString, adOpenForwardOnly, adLockReadOnly, adCmdText
        If rst.EOF Then
            MsgBox "The file currently in tblAEData does not appear to be in the ImportLog. " & _
                vbCrLf & "Please check and correct before proceeding."
            GoTo Exit_OutputEM_CDS_6_2_Net
        ElseIf rst(0) = 0 Then
            MsgBox "It appears that the activity hasn't been allocated yet. " & _
                vbCrLf & "Please check and correct before proceeding."
            GoTo Exit_OutputEM_CDS_6_2_Net
        Else
' the data has been allocated and is ready for exporting to SUS - a previous export does not prevent this export from running
        End If
        If rst.State = adStateOpen Then rst.Close
    End If
 
IS dbo.importlog as it used to be?
 

Users who are viewing this thread

Back
Top Bottom