trouble deleting with code during on click event of sub form

pb21

Registered User.
Local time
Today, 22:47
Joined
Nov 2, 2004
Messages
122
I have this code below that I hoped would find the record based on the coursebk id number of the current record in the subform, then seek it in the bookings table and delete it.

It doesnt work it returns error 3251 operation not supported for that type of object.

Help.......

regards

Dim db As DAO.Database
Set db = CurrentDb

Dim RstFtran As DAO.Recordset
Dim RstCourseBk As DAO.Recordset
Dim CourseBkID As String

Set RstCourseBk = db.OpenRecordset("Coursebk")
CourseBkID = Me!CourseBkID


With RstCourseBk
'**************** fails on line below.
.Seek "=", Val(CourseBkID)
If .NoMatch Then
MsgBox "No employee #" & CourseBkID & " in file!"
Else
.Delete
MsgBox "Record #" & CourseBkID & _
" deleted!"
End If
End With
 
pb,

You could try:

Code:
If DCount("[CourseBkID]", "Coursebk", "CourseBkID = " & Me.CourseBkID) = 0 Then
   MsgBox "No employee #" & CourseBkID & " in file!"
Else
   DoCmd.RunSQL "Delete From Coursebk Where CourseBkID = " & Me.CourseBkID)
   MsgBox "Record #" & CourseBkID & " deleted!"
End If

Wayne
 

Users who are viewing this thread

Back
Top Bottom