RecordsetClone.RecordCount

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like the message "No Records Found" to popup when I click on a
listbox in a subform that prompts an adjacent subform to provide results,
when no results exist. If results do exist, then I would like those results
visible.

I was using the following code I received from the discussion group with
success until I changed the database design from opening three different
forms to keeping just one form open, using multiple subforms:

Private Sub Form_Load()
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No records found."
DoCmd.Close
Else
Me.Visible = True
End If

End Sub
 
franklinbukoski said:
I would like the message "No Records Found" to popup when I click on a
listbox in a subform that prompts an adjacent subform to provide results,
when no results exist. If results do exist, then I would like those results
visible.

I was using the following code I received from the discussion group with
success until I changed the database design from opening three different
forms to keeping just one form open, using multiple subforms:

Private Sub Form_Load()
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "No records found."
DoCmd.Close
Else
Me.Visible = True
End If

End Sub


Assuming that subform2's record source query uses the list
box as a criteria, then the list box's AfterUpdate event
need to requery subform2 and then check it's record count:

Sub listbox_AfterUpdate()
With Parent.subform2.Form
.Requery
If .RecordsetClone.RecordCount = 0 Then
MsgBox "No records found."
End If
End With
 
Perfect, thank you!

Marshall Barton said:
Assuming that subform2's record source query uses the list
box as a criteria, then the list box's AfterUpdate event
need to requery subform2 and then check it's record count:

Sub listbox_AfterUpdate()
With Parent.subform2.Form
.Requery
If .RecordsetClone.RecordCount = 0 Then
MsgBox "No records found."
End If
End With
 
Back
Top