RecordsetClone.RecordCount

  • Thread starter franklinbukoski
  • Start date
F

franklinbukoski

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
 
M

Marshall Barton

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
 
F

franklinbukoski

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top