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 > Concatenation < Hyperlinks | Navigation >
Back to Concatenation    Comments List
Upload Images   @Reply   Bookmark    Link   Email  
Concatenation and IF Then Else
Robert Stott 
   
2 years ago
Trying this condition to set colors and enable a Button.

If MadeNotesChk.Value = True & IsNull([DocFileName] = True) Then
    PickBtn.Enabled = True
    Me.PickBtn.BackColor = RGB(100, 28, 30)
End If


There is more code this but this is what's relevant to my question. With & IsNull([DocFileName] = True) it doesn't work but if remove that part is works (enabled and colors button.

What's wrong with my code?
Alex Hedley  @Reply  
            
2 years ago
IsNull([DocFileName] = True)
to
IsNull([DocFileName]) = True
Alex Hedley  @Reply  
            
2 years ago
Say the [DocFileName] is "Fred", replace that in your condition:
IsNull([DocFileName] = True) becomes IsNull("Fred" = True) which becomes IsNull(False) which is False
Kevin Robertson  @Reply  
          
2 years ago
Try something like this.

If MadeNotesChk And IsNull(DocFileName) Then
    PickBtn.Enabled = True
    PickBtn.BackColor = RGB(100, 28, 30)
Else
    PickBtn.Enabled = False
End If
Robert Stott OP  @Reply  
   
2 years ago
I would like someone to look at this again: This time I am providing all of the Code

On the Form I have CheckBox("MadeNoteChk"), Comand Button ("Pickbtn"), TextBox(DocFileName") and then a Command Button("Openbtn").

What I am trying do is:  if the MadeNotesChk is checked then enable the Pickbtn. After a Document is picked the name populates the DocFileName. At this point I would like the OpenBtn to be enabled and change color while Pickbtn is Disabled and changes color.

If for some reason the MadeNotesChk is unchecked  I want both Command Buttons to be disabled and the DocFileName set Null.

I am lot further than I was but I still can't get the button operate right in each condition.

Here is the code:

DetailsPrivate Sub MadeNotesChk_Click()
If MadeNotesChk.Value = True Then
      
        If IsNull(DocFileName) = True Then
             PickBtn.Enabled = True
             PickBtn.BackColor = RGB(180, 90, 90)
             MsgBox "No Doc Enable PickBtn and change Color to Red"

        Else
             PickBtn.Enabled = False
             PickBtn.BackColor = RGB(50, 100, 150)
             OpenBtn.Enabled = True
             Me.OpenBtn.BackColor = RGB(180, 90, 90)
             MsgBox "Doc enables Pickbtn color blue and disable openbtn color red"

        End If

Else
    PickBtn.Enabled = False
    PickBtn.BackColor = RGB(50, 100, 150)
    OpenBtn.Enabled = False
    Me.OpenBtn.BackColor = RGB(50, 100, 150)
    Me.[DocFileName] = ""
    MsgBox "Not Check disable pick and open button color blue on both"
End If
    
End Sub


I have also tried putting the code in Form_Current and AfterUpdate for the CheckBox. I put the msg boxes in so I could tell were thing are working (or Not).
Kevin Robertson  @Reply  
          
2 years ago

Robert Stott OP  @Reply  
   
2 years ago
To start, Thanks Kevin for the input ( I am just learning about Sub Routines that you call from other subs. I haven't done this kind work for 30 years so I am really rusty, then I discovered Richard!
  
I had change this a little bit - It Sort of works, not the OpenBtn: I discovered if I go to next record and come back to the record the OpenBtn works.

I Added this -

Private Sub Form_Current()
    EnableDisableButtons
End Sub


And modified This -

Private Sub OpenBtn_Click()
'    MadeNotesChk = False 'This Didn't sim impact the effect on the button
    EnableDisableButtons
    FollowHyperlink CurrentProject.Path & "\documents\" & DocFileName
End Sub


So now I just need to discover why I have go to next then go back to the previous record for the button to work(I Thought the AfterUpdate would taken care of that. Any Thoughts?

Robert Stott OP  @Reply  
   
2 years ago
I just wanted to thank folks' again and let you know how I solved the final issue. I had this problem where I had to go to the next record and then go to previous record to get the function to kick in.

I put a reference to the function in  the AfterUpdate event but still no luck. After putting MsgBoxes where every the function was called I discovered that AfterUpdate was never called.

Then I discovered the event  called "Enter". I put a reference the the function there and now all the buttons work correctly.

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

 
 
 

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: 5/17/2025 8:45:37 PM. PLT: 2s