Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Access: how do you test for a blank sub form?

Posted on 2008-10-05
3
233 Views
Last Modified: 2013-11-28
Hello,

I would like to test an Access sub form using VBA to see if it's empty. If it is, I would like to modify controls on the main form.

The sub form does not allow edits, additions, or deletions. How do I test the sub form to find out when it's empty? Also, do I use the test in the main form onCurrent event?

Thanks
0
Comment
Question by:BradleyOnTheRoad
  • 2
3 Comments
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 22645781
Create a record set for the table or query of the subform where the link field = main form link field.
If rs.RecordCount=0 then
  'it is empty
End if

Ex:
Private Sub Command23_Click()
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("Select * from tblY where M= " & Me!M)
    If rs.RecordCount = 0 Then
        MsgBox ("Subform is empty")
   End If
End Sub
       
    rs.Close
0
 
LVL 30

Expert Comment

by:hnasr
ID: 22645788
SubForm tblY,  record source = tblY
Link fields=M
0
 

Author Closing Comment

by:BradleyOnTheRoad
ID: 31503232
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question