Solved

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

Posted on 2008-10-05
3
235 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
[X]
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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Menus 6 56
GA Ribbon creator 9 63
How to requery/refresh another form in VBA if you only know its name as a string. 5 52
Speed up Select Top n... Query 9 37
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

738 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