Message Box for Subform

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
 
K

kingston via AccessMonster.com

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]").
 
G

Guest

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
 
G

Guest

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
 
G

Guest

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
 

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