N
NH
I want to write a simple fucntion which will delete a specified record from
a table. I have written this, but it halts at the rs.findfirst line saying
that the operation is not supported for this type of object.....I have tried
all sorts of syntax changes, but still get the same error. Can anyone point
out what I have done wrong?
===========================================
Public Function DeleteRecord(ID As Integer)
If IsMissing(ID) Then Exit Function
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("MyTable")
rs.FindFirst "[ID] = " & ID
If not rs.NoMatch Then
rs.Delete
rs.Update
End If
Set rs = Nothing
End Function
============================================
Thanks
Nick
a table. I have written this, but it halts at the rs.findfirst line saying
that the operation is not supported for this type of object.....I have tried
all sorts of syntax changes, but still get the same error. Can anyone point
out what I have done wrong?
===========================================
Public Function DeleteRecord(ID As Integer)
If IsMissing(ID) Then Exit Function
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("MyTable")
rs.FindFirst "[ID] = " & ID
If not rs.NoMatch Then
rs.Delete
rs.Update
End If
Set rs = Nothing
End Function
============================================
Thanks
Nick