No Current Record (3021) Error (1 Viewer)

azlan

Registered User.
Local time
Today, 15:00
Joined
Aug 14, 2014
Messages
39
Hi There,
I get this error when I delete more than one record consecutively.
Here is my delete code;
Code:
Private Sub Komut98_Click()
Dim blnLast As Boolean
 
    'MsgBox call must return the value in order to be checked.
    'If user says no then cancelling is not required.  It is only required
    '  that the deletion command is not invoked.
    If MsgBox(Prompt:="Bu kaydı silmek istediğinizden eminmisiniz?" _
            , Buttons:=vbYesNo Or vbQuestion _
            , Title:="Deleting Record") = vbNo Then Exit Sub
    'At this point it's clear we need to delete the record.
    'Using With Me is a more efficient approach to object usage.
    With Me
        'Remember for later if record is last.
        blnLast = (.CurrentRecord = .Recordset.RecordCount)
        
        Call .Recordset.Delete
        
        'Only step back if deleted record was the last.
        If blnLast Then Call DoCmd.GoToRecord(Record:=acPrevious)
    End With
   
End Sub
Thank You...
 

JHB

Have been here a while
Local time
Tomorrow, 00:00
Joined
Jun 17, 2012
Messages
7,732
I think you need to requery the form, after you delete a record.
 

azlan

Registered User.
Local time
Today, 15:00
Joined
Aug 14, 2014
Messages
39
I think you need to requery the form, after you delete a record.
No, it did not work, I tried adding Me.Requery
Code:
If blnLast Then Call DoCmd.GoToRecord(Record:=acPrevious)
 Me.Requery
 

spikepl

Eledittingent Beliped
Local time
Tomorrow, 00:00
Joined
Nov 3, 2010
Messages
6,142
You are assuming that the record pointer by itself moves to some other record after you delete the current record. That is not so.
 

azlan

Registered User.
Local time
Today, 15:00
Joined
Aug 14, 2014
Messages
39
You are assuming that the record pointer by itself moves to some other record after you delete the current record. That is not so.
Well, what to do? What should I do?
 

azlan

Registered User.
Local time
Today, 15:00
Joined
Aug 14, 2014
Messages
39
Can anybody help me to code this;

  1. Navigate to the next record
  2. Capture the EventID value
  3. Navigate back to the "current" record
  4. Delete the current record
  5. Send a "message" from frmEventDetail to frmViewEventHistoryList. The "message" (typically, a call to a public procedure on frmViewEventHistoryList) contains the EventID value (as an argument to that public procedure).
  6. Finish closing frmEventDetail.
 

Users who are viewing this thread

Top Bottom