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 
YesNo field VBA help
Robert Freeman 
      
3 years ago
I have a member database with a yes/no field which when set to yes displays a subform where the group or groups which the member belongs to can be selected from a list. I need to make sure that if a member ceases to belong to a group the checkbox cannot be turned off until after a message box is displayed and action taken to remove them from the list of groups.
Is there a way of doing this with VBA.

The current vba for the yes/no checkbox is as follows:

Private Sub Form_Current()

    MemberGroupSubF.Visible = GroupLeader

End Sub

Private Sub GroupLeader_AfterUpdate()

If GroupLeader Then
        MemberGroupSubF.Visible = True
        
            MsgBox "Select All The Groups for which this Member is Leader:" & vbNewLine & " " & vbNewLine & _
                "You can also De-Select a Group's Name by Selecting the Row and Pressing Delete on the Keyboard", vbInformation, "Group Leader Selection"
    
    Else
        MemberGroupSubF.Visible = False
End If

End Sub
Richard Rost  @Reply  
          
3 years ago
So you're saying you don't want them to be able to un-check the box until the person has been removed from all groups?
Kevin Yip  @Reply  
     
3 years ago
If the user wants to remove a member but later changes his mind, how do you let him use the checkbox again, since you disallowed him to do so just a moment ago?  So the method you described may not work (or work ideally) in that case.  A better way to do this is that when the user is *inside* the subform (i.e. subform has focus), disable the check box.  The moment he leaves the subform, enable the checkbox again.  You need some careful usages of the subform's GotFocus and LostFocus events, and maybe some other ones too.
Richard Rost  @Reply  
          
3 years ago
You could use a before update event in the checkbox itself and don't let them uncheck it if there are any items still in the subform.
Robert Freeman OP  @Reply  
      
3 years ago
Hi. Thanks for the replies. Richard, Your first reply is exactly correct. Your second reply - the before update event would have to apply to that specific member's entry in the sub-form.  I'm still learning all this stuff (I'm up to Expert 7) so have you covered what I should be looking at in a tech help video or lesson? If so can you please point me in the right direction so I can try and figure it out myself. I'll re-post the question if I can't do that myself and need more help with the VBA. Appreciate you help - happy Labor day!
Kevin Robertson  @Reply  
          
3 years ago
These videos should help you accomplish what you need.

DCount
Before Update
If Then
Robert Freeman OP  @Reply  
      
3 years ago
Thanks for all your comments but despite a few hours trying I can't figure this one out. I guess more experience needed!

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/7/2026 12:49:00 AM. PLT: 2s