zz error 2147352567 when trying to delete a record

  • Follow


I am receiving error 2147352567 when trying to delete  a record from
form 1Cruise. The error is happening in a function that calculates and
sends a total weight to a text box. The delete never completes.

The code in the function is as follows and it errors when checking the
setid in the first if statement when attempting the delete but works
fine otherwise.

Public Function GetTotalWeight() As Double
    On Error GoTo ErrHandler


    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strSQL As String
    Dim intCriteria As Long

    'If Not IsNull([Forms]![Form1]![1Cruise].[Form]![CruiseID]) Then

    If Not IsNull([Forms]![Form1]![1Cruise].[Form]![1Sets].[Form]!
[SetID]) Then
        strSQL = "SELECT Sum([1CatchComposition].[Weight (kg)]) AS
[SumOfWeight (kg)], [1CatchComposition].SetIDFK " & _
                    "FROM 1CatchComposition " & _
                    "GROUP BY [1CatchComposition].SetIDFK " & _
                    "HAVING [1CatchComposition].SetIDFK=" & _
                    [Forms]![Form1]![1Cruise].[Form]![1Sets].[Form]!
[SetID] & ";"

        Set db = CurrentDb
        Set rs = db.OpenRecordset(strSQL)

        If Not rs.EOF Then
            If Not IsNull(rs.Fields("[SumOfWeight (kg)]")) Then
                GetTotalWeight = rs.Fields("[SumOfWeight (kg)]")
            End If
        Else
            GetTotalWeight = 0
        End If
    End If
   'End If

ErrHandler:
    If Err.Number = 0 Then
    Else
        MsgBox Err.Number & "  " & Err.Description & "  " & "has
occurred in GetTotalWeight."
    End If




End Function

0
Reply davjoh123 3/11/2010 9:09:25 PM


0 Replies
382 Views

(page loaded in 0.018 seconds)


Reply: