OnCurrent doesn't fire when no records on subform

  • Thread starter Thread starter Mike Dwyer
  • Start date Start date
M

Mike Dwyer

I have a subform linked to a master form. The subform is set not to
allow additions. When the master changes and there are no records in
the subform, the Oncurrent event doesn't fire.

I do understand why this is, but what I want to know is Is there any
way to trap this "no records" situation? In other words, can I trap
for this and act accordingly?

Thanks in advance.

-Mike
 
Not sure if this works correctly but you can try the RecordCount of the
Subform's Recordset.
 
Mike Dwyer said:
I have a subform linked to a master form. The subform is set not to
allow additions. When the master changes and there are no records in
the subform, the Oncurrent event doesn't fire.

I do understand why this is, but what I want to know is Is there any
way to trap this "no records" situation? In other words, can I trap
for this and act accordingly?

Thanks in advance.

-Mike

I expect that in the Current event of the parent form you can check the
RecordCount property of the Recordset of the subform, and act
accordingly; e.g.,

Private Sub Form_Current()

With Me.sfMySubform.Form
If .Recordset.RecordCount = 0 Then
' do something
End If
End With

End Sub

I'm not 100% sure about this, because I'm not sure at what point the
subform's recordset is loaded and filtered by the Link Master/Child
Fields. But it's worth a try.
 
Well I would like the subform to respond to the fact that it has no
records. In particular, I'd like to see a message on the subform that
says "Sorry, There Are No Widgets" instead of a bunch of blank fields.
In the past, I've handled this by dynamically setting the
recordsource of the subform during the OnCurrent event of the parent.
I then check the recordcount and act accordingly. However, I was
wondering if there was some simpler way of doing things.

-Mike
 
Back
Top