Message Box for Subform

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

Guest

Hello,
I have a subform linked to a unbound textbox. Everything works great when
you enter data into the unbound textbox if it's in the query. If you enter
something that is not in the query the subform stays blank. Is there away to
have a message box appear if there is no data come after you enter it in the
textbox for the subform.

Thank you
David
 
Check the record count prior to opening the subform (after the textbox is
updated). If he record count is zero, then suppress the subform and open a
message box instead. If you have a saved query, you can check the number of
records using: DCount("*","[QueryName]").
 
Hi,
check the query in the after update event of the control e.g.:

If Dcount("*","YourQuery") = 0 Then
MsgBox("No Record")
End If

HTH
Good luck
 
Hello,

Thank you guys for the suggestions, but neither worked so far.

Can I have something the query that subform is based on? Like with Sql or
condition is the query design?

Thank you, Again

David
 
Hi,
why hasn't it worked?
Are you receiving an error?
Is the subform based off this query? Are you using the right event to check
the query?
You could also try to use the RecordCount property of the RecordSetClone
method to check the subform itself e.g.

If Me.YourSubform.Form.RecordsetClone.RecordCount = 0 Then
....

But the Dcount() should have worked as well.
HTH
Good luck
 
Back
Top