Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Subform Control Name
Sandra Truax 
         
2 years ago
I've tried everything I can think of, even ChatGPT and Open AI, and still have not been able to figure this out, so hoping one of y'all might help, purty please.

I'm trying to write some code/function that will pull the name of the parent form and the subform that I am currently in. For example: Forms!Budget!Transactions.Form

I know that Screen.ActiveForm.Name will give me the Budget part of it, but I can't get anything to give me the "Transactions" part of it.

I know I'm being lazy by not just typing it out  but thought if I could just click a button I could then assigne it to a TempVars to use in my code.

Any help will be greatly appreciate.
Sami Shamma  @Reply  
             
2 years ago
Have you tried the "Parent" property?
Sandra Truax OP  @Reply  
         
2 years ago
I can get the name of the parent form, just not the subform.  I'm not sure what you mean by the "Parent" property.
Kevin Robertson  @Reply  
           
2 years ago
Dim ctrl As Control
    
For Each ctrl In Me.Controls
    If ctrl.ControlType = acSubform Then
        MsgBox ctrl.Name
    End If
Next


For Each Loop
Sandra Truax OP  @Reply  
         
2 years ago
Thanks Kevin. This works from the parent form. If I have multiple subforms, is there a way to run this from within a subform and it give me the name of the subform that is active instead of looping through them?
Kevin Robertson  @Reply  
           
2 years ago
Screen.ActiveForm.ActiveControl.Name
Sandra Truax OP  @Reply  
         
2 years ago
Kevin, when I put that in a button in a sub form, it gave me a compile error: Invalid use of property and highlighted the ".name " part of the code.
Kevin Robertson  @Reply  
           
2 years ago
You do need to store the value in a variable.

    Dim subName As String
    
    subName = Screen.ActiveForm.ActiveControl.Name
    MsgBox subName
Sandra Truax OP  @Reply  
         
2 years ago
Thank you Kevin!  That works!  Now hopefully I can get it all pieced together for a function I can call from any form.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/9/2026 3:45:39 PM. PLT: 1s