Error 3021

spencers

Registered User.
Local time
Today, 22:23
Joined
Dec 9, 2003
Messages
13
Hello,

I have search previous threads on this problem and not been able to solve it....so if there are any new ideas on this I would appreciate your help.

Firstly I open a new form "Document Details" from a subform which filters out a single record thus

Private Sub Command116_Click()
On Error GoTo Err_Command116_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Document Details"
stLinkCriteria = "[Fileandrev]=" & "'" & Me![Filename] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command116_Click:
Exit Sub

Err_Command116_Click:
MsgBox Err.Description
Resume Exit_Command116_Click

End Sub

If I then try and delete the record using the following

DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

It of course...as many others have discovered goes into the error 3021
because there is no current record for the form to move to because it
is filtered from the above statement

DoCmd.OpenForm stDocName, , , stLinkCriteria

All I need to do is close the form after the error message and refresh the subform so it removes the deleted record which I know I can do by placing the commands after the error description....but it would be nice to know how
to do it properly rather than bodge it ..!!

Any ideas please

Thanks in anticipation :)
 
Have you tried opening a recordset containing the record in question, navigating to it and then deleting it? There are lots of examples of handling recordsets around here so you should be able to find some suitable code.

You could place this code in the OnClick event that you use to delete the record, using the criteria that you already have to isolate it; and closing the form down in the process...

Tim
 
Thanks

Tim...I will try your idea...recordsets are something I have just touched the surface on so far....I just needed pointing in the right direction...thanks

Watch this space

Steve
 

Users who are viewing this thread

Back
Top Bottom