Hello, When I run this function I get an error that says "Can't not find Table or query". The error is on the line Set rsDelete = CurDB.OpenRecordset(strSQL)
Any ideas?
Thanks
Jim
Code:
Public Function DeleteRoutine(ID As Integer) As Boolean
Debug.Print
Dim IDToDelete As Integer
IDToDelete = ID
Dim strSQL As String
Dim strSQLD As String
Dim CurDB As DAO.Database
Set CurDB = CurrentDb
Dim rsDelete As DAO.Recordset
strSQL = "tblCurrentStatus.tblCurrentStatusPK, " & _
"tblCurrentStatus.tblHistoryID, " & _
"tblCurrentStatus.tblReferralID, " & _
"tblCurrentStatus.Status, " & _
"tblCurrentStatus.OnTheListStatus, " & _
"tblCurrentStatus.StatusDate, " & _
"tblCurrentStatus.IndexNumber, " & _
"tblCurrentStatus.DateWritten, " & _
"tblCurrentStatus.TicketNumber " & _
" FROM tblCurrentStatus" & _
" WHERE (((tblCurrentStatus.tblHistoryID)=" & IDToDelete & "))"
strSQLD = "delete tblCurrentStatus.tblCurrentStatusPK, " & _
"tblCurrentStatus.tblHistoryID, " & _
"tblCurrentStatus.tblReferralID, " & _
"tblCurrentStatus.Status, " & _
"tblCurrentStatus.OnTheListStatus, " & _
"tblCurrentStatus.StatusDate, " & _
"tblCurrentStatus.IndexNumber, " & _
"tblCurrentStatus.DateWritten, " & _
"tblCurrentStatus.TicketNumber " & _
" FROM tblCurrentStatus" & _
" WHERE (((tblCurrentStatus.tblHistoryID)=" & IDToDelete & "))"
Set rsDelete = CurDB.OpenRecordset(strSQL)
If Not rsDelete.BOF And Not rsDelete.EOF Then
rsDelete.FindFirst "tblhistoryID= " & IDToDelete & ""
DoCmd.RunSQL (strSQLD)
DeleteRoutine = True
Else
DeleteRoutine = False
End If
rsDelete.Close
Set rsDelete = Nothing
End Function
Thanks
Jim