Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Vehicle Maintenance < Cascading Combo Boxes | Relational Combo >
Back to Vehicle Maintenance    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Subform Selected on Field
Sandra Truax 
          
3 years ago
I'm getting there, but I'm stuck. I have designed a form for my family, and I have two subforms that I switch between "ChildOfFatherF" and "ChildOfMotherF" my clicking either a "Female" button or a "Male" button depending on the sex of the person (as explained in this video).

How can I select the object source with an if then else statement (or some other way) that will automatically choose the right form depending on the sex of the person pulled up?
Adam Schwanz  @Reply  
            
3 years ago
Use DLookup to find if male or female and open the form.

If DLOOKUP("Sex","Table","ID=" & ID) = "Male" Then
docmd.openform "MaleForm"
ElseIf DLOOKUP("Sex","Table","ID=" & ID) = "Female" Then
docmd.openform "FemaleForm"
End If
Kevin Yip  @Reply  
     
3 years ago
Just open both forms, then set them visible or invisible depending on gender.
Sandra Truax OP  @Reply  
          
3 years ago
I just wanted to say to Kevin Yip, thank you, thank you, thank you.  This worked perfect!

If Forms!FamilyDetailF!Sex = "F" Then
        Forms!FamilyDetailF!ChildOfFatherF.Visible = False
    Else
        Forms!FamilyDetailF!ChildOfFatherF.Visible = True
    End If
Sandra Truax OP  @Reply  
          
3 years ago
I just want to say thanks to Adam Schwanz.  I couldn't ever get this to work, but I'm sure it was something I was doing wrong. I now have it working using the suggestion from Kevin Yip.
Adam Schwanz  @Reply  
            
3 years ago
Nope that was my mistake, I missed the "subform" part, it still would have worked but would have had to word it a little differently.
Adam Schwanz  @Reply  
            
3 years ago
Would have had to do like

Subform.SourceObject="MaleForm" instead of docmd.openform
Sandra Truax OP  @Reply  
          
3 years ago
Thanks Adam Schwanz.  I will add this to my notes for future use.
Kevin Yip  @Reply  
     
3 years ago
Sandra, you're welcome.  I use this trick quite often when I have to juggle several forms.  I'd rather have all the forms opened up at the start (and set their visibility accordingly) than open and close the forms every single time because that has the potential of much headache.

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

Next Unseen

 
 
 

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 2025 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 12/9/2025 7:02:26 PM. PLT: 1s