Hi,
Before I delete a record on from a form, I want to check and see if that ID exists in another table, If so I want to discouninue the delete procedure, here is my code:
(I'm using a SQL server backend)
Dim CSet As ADODB.Recordset
Dim strSQL
strSQL = "Exec dbo.SP_FindCompanyOnDelete " & Me!CompanyID
Set CSet = New ADODB.Recordset
CSet.ActiveConnection = CurrentProject.Connection
CSet.Open strSQL
If CSet.EOF Then
CSet.Close
Exit Sub
Else
CSet.Close
MsgBox "There are Contacts assigned to this company." _
& Chr(13) & "Delete the company from those contacts first and then delete the Company.", vbCritical, "Delete Responses First"
End If