No Current Record - unknown source

nschroeder

nschroeder
Local time
Today, 14:50
Joined
Jan 8, 2007
Messages
186
I am receiving the No Current Record message, but have been unable to determine the code that generates it. The database is a system that creates tasks and assigns them to users. In the header section of the Tasks form are several controls they can use to select Active or Completed tasks, refresh the data, sort by columns, etc. There are also three other forms (not subforms) that lay on top of the Tasks form to provide additional detail about the current task.

If they "complete" all their active tasks and click Refresh, all the tasks disappear, as they should, and everything works fine. If they then try to close the form, or click any control in the Tasks header, the No Current Record message pops up. I've put debug stops in every conceivable location, but the message appears to occur before any code is activated.

I did find that I can make the message not occur by commenting out the code that synchronizes one of the associated forms (Notes), but I still don't know what is triggering the message. Debug stops in Notes yield no results either, and clicking a control in the header of Tasks shouldn't affect Notes.

Any suggestions on how to find out what's triggering the message?

Thanks
 
Note the 4 lines commented out. SynchronizeLinkedForms is also called from other places. The intent is that if a record with accompanying notes is selected, the Notes form is made visible. Otherwise, it's hidden. Keep in mind, though, that none of this code is being hit when the message occurs.

Code:
Private Sub Form_Current()
    Call SynchronizeLinkedForms
End Sub

Sub SynchronizeLinkedForms()
    If FormIsLoaded("EAccessDetail") Then
        Forms!EAccessDetail.Requery
    End If
    If FormIsLoaded("EAccessPrev") Then
        Forms!EAccessPrev.Requery
    End If
'    If Not FormIsLoaded("EAccessNotes") Then
'       Call OpenEAForm("EAccessNotes")
'    End If
'    Call SynchronizeNotes
    Me.Repaint
End Sub

Sub SynchronizeNotes()
    With Forms!EAccessNotes
        If Me.Recordset.RecordCount = 0 Then
            .Visible = False
        Else
            .Requery
            If .Recordset.RecordCount = 0 Then
                .Visible = False
            Else
                .Visible = True
                .EANum.DefaultValue = Me.EANum
                .SetFocus
            End If
        End If
        tglShowNotes.Value = .Visible
    End With
End Sub

Private Sub Form_Close()
    DoCmd.Restore
    On Error Resume Next
    Call CloseEAForm("EAccessDetail")
    Call CloseEAForm("EAccessPrev")
    Call CloseEAForm("EAccessNotes")
End Sub
 
So commenting out the code suppresses the message but that routine never runs??? There must be an error in your observation. Commenting out code that never runs cannot have any effect.
 
Didn't say it never runs. It's just not active when the message pops up. Here's the sequence of events:
1. User has one or more active tasks, and marks them as complete.
2. User clicks the Refresh button, which refreshes the form data (filtered to include only active tasks) and calls SynchronizeLinkedForms. So far, so good. The form now shows no records.
3. User closes the form or clicks any control in the header (Refresh button, Option button to switch to Completed tasks, etc.). Error message pops up before any debug stops are hit.

If code (run in step 2) is commented out, then the error does not occur in step 3.
It doesn't make sense to me either!
 
If you want to post the DB I'll take a look. Maybe you can chop out a bunch of stuff that doesn't have any bearing on the prob.

But a suggestion too. Subforms and ComboBoxes and ListBoxes all support their own recordsets which might be automatically requeried based on how they are defined in design view, so a subform--based on the LinkMasterFields and LinkChildFields properties--or a ComboBox or ListBox, may automatically requery its underlying recordset and fail to have a current record, or fail based on some parameter that is no longer available, and these events occur outside the scope of VBA.
 

Users who are viewing this thread

Back
Top Bottom