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 Developer Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Disabling a Form Button Based on Tempvar
Daniel Golden 
     
15 months ago
I have added a button to my forms in which I have appended the code below in the On Current event:

DetailsPrivate Sub Form_Current()
    ' Check if the TempVar "username" exists
    If Not IsNull(TempVars!username) Then
        ' Compare the TempVar value with the ComboBox value
        If TempVars!username = Me.combo15.Value Then
            ' Enable the button if the values match
            Me.mvflbtn.Enabled = True
        Else
            ' Disable the button if the values do not match
            Me.mvflbtn.Enabled = False
        End If
    Else
        ' Disable the button if the TempVar does not exist
        Me.mvflbtn.Enabled = False
    End If
End Sub


What I am wanting to happen is the button named "MvFlBtn" should be disabled unless the value of combo15 equals the TempVar which is set upon login of the user. Currently, the way it works with this code is the button is disabled no matter the TempVar. I have a record with my name as the assigned investigator and the button is still disabled.
Thomas Gonder  @Reply  
      
15 months ago
Have you checked the variables by placing a break point on these lines?:
If Not IsNull(TempVars!username) Then
If TempVars!username = Me.combo15.Value Then
Daniel Golden OP  @Reply  
     
15 months ago
I should have paid closer attention to the code I pasted in above. I do not have the first one for If Not IsNull... I know the TempVar exists so there is no need to check for it.
Kevin Robertson  @Reply  
          
15 months ago
Is the Username in the first column of the Combo Box? If not, you will need to access the Column property,
For example: Combo15.Column(1)

Make sure you give your controls good names especially if referring to them in code.
Julie Bennett  @Reply  
     
15 months ago
In case you think giving controls a valid name is a waste of time...  I had a minor stroke and barely remember how to code in Access.  I had to fix a broken, complex database.  If it had not been for Richard and others instilling the need for naming controls properly, I would have had to throw the d/base away and somehow start again.  Whilst it has been a hard slog to fix my broken database, at least I was able to re-use most of what I had first written.  So, think about future you (and future users of your code) and please name your controls.
Daniel Golden OP  @Reply  
     
15 months ago
@Kevin, I will check that out later today/tonight and see.

@Julie,  that’s a very good point! I’m going to take the time to go through this database and rename all generically named controls.
John Davy  @Reply  
         
15 months ago
Hi Daniel, I totally agree with Julie and am sure you see the benefit. I just want to share (I am not selling or promoting a product) but I use a program Access Dev Tools by Philipp Steifel from Germany that is invaluable to finding and replacing. In a second it will fix each generic name and make it whatever you want. HTH John
Sami Shamma  @Reply  
             
15 months ago
Access Dev Tools by Philipp Steifel from Germany is excellent tool. Be careful, very powerful.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Developer 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 6:24:04 AM. PLT: 0s